Skip to content

Commit 033a6fb

Browse files
authored
Merge pull request #929 from jkroepke/exclude-hostnetwork-pod
network: Exclude pods running in host network
2 parents 18eac81 + d63872c commit 033a6fb

File tree

3 files changed

+62
-44
lines changed

3 files changed

+62
-44
lines changed

dashboards/network-usage/cluster-total.libsonnet

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ local var = g.dashboard.variable;
6767
+ tsPanel.queryOptions.withTargets([
6868
prometheus.new(
6969
'${datasource}',
70-
'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
70+
'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
7171
)
7272
+ prometheus.withLegendFormat('__auto'),
7373
]),
@@ -77,43 +77,43 @@ local var = g.dashboard.variable;
7777
+ tsPanel.queryOptions.withTargets([
7878
prometheus.new(
7979
'${datasource}',
80-
'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
80+
'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
8181
)
8282
+ prometheus.withLegendFormat('__auto'),
8383
]),
8484

8585
table.new('Current Status')
8686
+ table.gridPos.withW(24)
8787
+ table.queryOptions.withTargets([
88-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
88+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
8989
+ prometheus.withInstant(true)
9090
+ prometheus.withFormat('table'),
9191

92-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
92+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
9393
+ prometheus.withInstant(true)
9494
+ prometheus.withFormat('table'),
9595

96-
prometheus.new('${datasource}', 'avg by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
96+
prometheus.new('${datasource}', 'avg by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
9797
+ prometheus.withInstant(true)
9898
+ prometheus.withFormat('table'),
9999

100-
prometheus.new('${datasource}', 'avg by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
100+
prometheus.new('${datasource}', 'avg by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
101101
+ prometheus.withInstant(true)
102102
+ prometheus.withFormat('table'),
103103

104-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
104+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
105105
+ prometheus.withInstant(true)
106106
+ prometheus.withFormat('table'),
107107

108-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
108+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
109109
+ prometheus.withInstant(true)
110110
+ prometheus.withFormat('table'),
111111

112-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
112+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
113113
+ prometheus.withInstant(true)
114114
+ prometheus.withFormat('table'),
115115

116-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
116+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
117117
+ prometheus.withInstant(true)
118118
+ prometheus.withFormat('table'),
119119
])
@@ -214,7 +214,7 @@ local var = g.dashboard.variable;
214214
+ tsPanel.queryOptions.withTargets([
215215
prometheus.new(
216216
'${datasource}',
217-
'avg by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
217+
'avg by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
218218
)
219219
+ prometheus.withLegendFormat('__auto'),
220220
]),
@@ -224,7 +224,7 @@ local var = g.dashboard.variable;
224224
+ tsPanel.queryOptions.withTargets([
225225
prometheus.new(
226226
'${datasource}',
227-
'avg by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
227+
'avg by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
228228
)
229229
+ prometheus.withLegendFormat('__auto'),
230230
]),
@@ -234,7 +234,7 @@ local var = g.dashboard.variable;
234234
+ tsPanel.queryOptions.withTargets([
235235
prometheus.new(
236236
'${datasource}',
237-
'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
237+
'sum by (namespace) (rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
238238
)
239239
+ prometheus.withLegendFormat('__auto'),
240240
]),
@@ -244,50 +244,50 @@ local var = g.dashboard.variable;
244244
+ tsPanel.queryOptions.withTargets([
245245
prometheus.new(
246246
'${datasource}',
247-
'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config
247+
'sum by (namespace) (rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
248248
)
249249
+ prometheus.withLegendFormat('__auto'),
250250
]),
251251

252252
tsPanel.new('Rate of Received Packets')
253253
+ tsPanel.standardOptions.withUnit('pps')
254254
+ tsPanel.queryOptions.withTargets([
255-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
255+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
256256
+ prometheus.withLegendFormat('__auto'),
257257
]),
258258

259259
tsPanel.new('Rate of Transmitted Packets')
260260
+ tsPanel.standardOptions.withUnit('pps')
261261
+ tsPanel.queryOptions.withTargets([
262-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
262+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
263263
+ prometheus.withLegendFormat('__auto'),
264264
]),
265265

266266
tsPanel.new('Rate of Received Packets Dropped')
267267
+ tsPanel.standardOptions.withUnit('pps')
268268
+ tsPanel.queryOptions.withTargets([
269-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
269+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
270270
+ prometheus.withLegendFormat('__auto'),
271271
]),
272272

273273
tsPanel.new('Rate of Transmitted Packets Dropped')
274274
+ tsPanel.standardOptions.withUnit('pps')
275275
+ tsPanel.queryOptions.withTargets([
276-
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]))' % $._config)
276+
prometheus.new('${datasource}', 'sum by (namespace) (rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
277277
+ prometheus.withLegendFormat('__auto'),
278278
]),
279279

280280
tsPanel.new('Rate of TCP Retransmits out of all sent segments')
281281
+ tsPanel.standardOptions.withUnit('percentunit')
282282
+ tsPanel.queryOptions.withTargets([
283-
prometheus.new('${datasource}', 'sum by (instance) (rate(node_netstat_Tcp_RetransSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) / rate(node_netstat_Tcp_OutSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]))' % $._config)
283+
prometheus.new('${datasource}', 'sum by (instance) (rate(node_netstat_Tcp_RetransSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) / rate(node_netstat_Tcp_OutSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
284284
+ prometheus.withLegendFormat('__auto'),
285285
]),
286286

287287
tsPanel.new('Rate of TCP SYN Retransmits out of all retransmits')
288288
+ tsPanel.standardOptions.withUnit('percentunit')
289289
+ tsPanel.queryOptions.withTargets([
290-
prometheus.new('${datasource}', 'sum by (instance) (rate(node_netstat_TcpExt_TCPSynRetrans{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) / rate(node_netstat_Tcp_RetransSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]))' % $._config)
290+
prometheus.new('${datasource}', 'sum by (instance) (rate(node_netstat_TcpExt_TCPSynRetrans{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) / rate(node_netstat_Tcp_RetransSegs{%(clusterLabel)s="$cluster"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config)
291291
+ prometheus.withLegendFormat('__auto'),
292292
]),
293293
];

0 commit comments

Comments
 (0)