diff --git a/grafana-dashboards/Makefile b/grafana-dashboards/Makefile index 2bbe17b..baeb102 100644 --- a/grafana-dashboards/Makefile +++ b/grafana-dashboards/Makefile @@ -1,13 +1,14 @@ # Generate json dashboards TARGETS= pergamon.filesystem.sizes.json pergamon.cpu.usage.json \ pergamon.uptime.json pergamon.loadavg.json \ - pergamon.memory.usage.json + pergamon.memory.usage.json pergamon.swap.json \ + pergamon.network.traffic.json default: $(TARGETS) %.json: %.py generate-dashboard -o $@ $< clean: rm $(TARGETS) diff --git a/grafana-dashboards/pergamon.network.traffic.py b/grafana-dashboards/pergamon.network.traffic.py new file mode 100644 index 0000000..ae3a439 --- /dev/null +++ b/grafana-dashboards/pergamon.network.traffic.py @@ -0,0 +1,56 @@ +from grafanalib.core import * + +def network_graph(device, time_from=None): + if time_from is not None: + timeFrom = "%s" % (time_from,) + else: + timeFrom = None + return Graph( + title='Network traffic', + dataSource="Prometheus", + timeFrom=timeFrom, + stack=True, + tooltip=Tooltip(valueType=INDIVIDUAL), + targets=[ + Target( + expr='irate(node_network_receive_bytes_total{instance="192.168.100.29:9100",device="%s"}[5m])' % (device), + legendFormat="bytes per second in", + refId='A', + ), + Target( + expr='irate(node_network_transmit_bytes_total{instance="192.168.100.29:9100",device="%s"}[5m])' % (device), + legendFormat="bytes per second out", + refId='B', + ), + ], + yAxes=[ + YAxis(format='decbytes'), + YAxis(format=SHORT_FORMAT), + ], + legend=Legend(max=True, min=True, avg=True, current=True), + ) + +dashboard = Dashboard( + title="Pergamon network traffic auto-generated", + templating=Templating(list=[ + Template( + name="interface", + label="", + query='node_arp_entries{instance="192.168.100.29:9100"}', + regex='/device="([^"]*)/', + dataSource='Prometheus', + includeAll=True, + default="All", + hide = 2, + ), + ]), + rows=[ + Row( + title = '$interface traffic', + panels=[ + network_graph("$interface"), + network_graph("$interface","1y"), + ], + repeat = 'interface', + ), + ],).auto_panel_ids() diff --git a/grafana-dashboards/pergamon.swap.py b/grafana-dashboards/pergamon.swap.py new file mode 100644 index 0000000..4af19d4 --- /dev/null +++ b/grafana-dashboards/pergamon.swap.py @@ -0,0 +1,40 @@ +from grafanalib.core import * + +def swap_activity_graph(time_from=None): + if time_from is not None: + timeFrom = "%s" % (time_from,) + else: + timeFrom = None + return Graph( + title='Swap activity', + dataSource="Prometheus", + timeFrom=timeFrom, + targets=[ + Target( + expr='irate(node_vmstat_pswpin{instance="192.168.100.29:9100"}[5m])', + legendFormat="pages per second in", + refId='A', + ), + Target( + expr='irate(node_vmstat_pswpout{instance="192.168.100.29:9100"}[5m])', + legendFormat="pages per second out", + refId='B', + ), + ], + yAxes=[ + YAxis(format=SHORT_FORMAT), + YAxis(format=SHORT_FORMAT), + ], + ) + +dashboard = Dashboard( + title="Pergamon swap usage auto-generated", + rows=[ + Row( + title = 'Swap', + panels=[ + swap_activity_graph(), + swap_activity_graph("1y"), + ], + ), + ],).auto_panel_ids()