Skip to content

Commit a6ed081

Browse files
committed
Pod dashboard: add restart annotation.
Although this does not give exact restart ocurrences in case of restart loop, this gives a good representation of what is happening.
1 parent 0669b54 commit a6ed081

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dashboards/pods.libsonnet

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local grafana = import 'grafonnet/grafana.libsonnet';
2+
local annotation = grafana.annotation;
23
local dashboard = grafana.dashboard;
34
local graphPanel = grafana.graphPanel;
45
local prometheus = grafana.prometheus;
@@ -78,11 +79,23 @@ local numbersinglestat = promgrafonnet.numbersinglestat;
7879
legend_avg=true,
7980
)
8081
.addTarget(prometheus.target(
81-
'sort_desc(sum by (pod_name) (rate(container_network_receive_bytes_total{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", namespace="$namespace", pod_name="$pod"}[1m])))' % $._config,
82+
'sort_desc(sum by (pod_name) (rate(container_network_receive_bytes_total{%(cadvisorSelector)s, %(clusterLabel)s="$cluster", %(clusterLabel)s="$cluster", namespace="$namespace", pod_name="$pod"}[1m])))' % $._config,
8283
legendFormat='{{ pod_name }}',
8384
))
8485
);
8586

87+
local restartAnnotation = annotation.datasource(
88+
'Restarts',
89+
'$datasource',
90+
expr='time() == BOOL timestamp(deriv(kube_pod_container_status_restarts_total{%(kubeStateMetricsSelector)s, %(clusterLabel)s="$cluster", namespace="$namespace", pod="$pod"}[2m]) > 0)',
91+
enable=true,
92+
hide=false,
93+
iconColor='rgba(215, 44, 44, 1)',
94+
tags=['restart'],
95+
type='rows',
96+
builtIn=1,
97+
);
98+
8699
dashboard.new(
87100
'%(dashboardNamePrefix)sPods' % $._config.grafanaK8s,
88101
time_from='now-1h',
@@ -142,6 +155,7 @@ local numbersinglestat = promgrafonnet.numbersinglestat;
142155
includeAll=true,
143156
)
144157
)
158+
.addAnnotation(restartAnnotation)
145159
.addRow(memoryRow)
146160
.addRow(cpuRow)
147161
.addRow(networkRow),

0 commit comments

Comments
 (0)