Skip to content

Commit

Permalink
fix: Error "multiple matches for labels: many-to-one matching must be…
Browse files Browse the repository at this point in the history
… explicit (group_left/group_right)" on Kubernetes/Networking Dashboards

Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Aug 6, 2024
1 parent 2ea98c7 commit de92283
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 30 deletions.
26 changes: 24 additions & 2 deletions dashboards/network-usage/cluster-total.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,36 @@ local var = g.dashboard.variable;
tsPanel.new('Rate of TCP Retransmits out of all sent segments')
+ tsPanel.standardOptions.withUnit('percentunit')
+ tsPanel.queryOptions.withTargets([
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)
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) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),

tsPanel.new('Rate of TCP SYN Retransmits out of all retransmits')
+ tsPanel.standardOptions.withUnit('percentunit')
+ tsPanel.queryOptions.withTargets([
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)
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) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),
];
Expand Down
172 changes: 154 additions & 18 deletions dashboards/network-usage/namespace-by-pod.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ local var = g.dashboard.variable;
])
+ gauge.queryOptions.withTargets([
prometheus.new(
'${datasource}',
'sum(rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
'${datasource}', |||
sum (
rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),
Expand Down Expand Up @@ -132,36 +140,104 @@ local var = g.dashboard.variable;
])
+ gauge.queryOptions.withTargets([
prometheus.new(
'${datasource}',
'sum(rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"})' % $._config
'${datasource}', |||
sum (
rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),
table.new('Current Network Usage')
+ table.gridPos.withW(24)
+ table.queryOptions.withTargets([
prometheus.new('${datasource}', 'sum(rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),

prometheus.new('${datasource}', 'sum(rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),

prometheus.new('${datasource}', 'sum(rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),

prometheus.new('${datasource}', 'sum(rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),

prometheus.new('${datasource}', 'sum(rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),

prometheus.new('${datasource}', 'sum(rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config)
+ prometheus.withInstant(true)
+ prometheus.withFormat('table'),
])
Expand Down Expand Up @@ -254,8 +330,16 @@ local var = g.dashboard.variable;
+ tsPanel.standardOptions.withUnit('binBps')
+ tsPanel.queryOptions.withTargets([
prometheus.new(
'${datasource}',
'sum(rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),
Expand All @@ -264,37 +348,89 @@ local var = g.dashboard.variable;
+ tsPanel.standardOptions.withUnit('binBps')
+ tsPanel.queryOptions.withTargets([
prometheus.new(
'${datasource}',
'sum(rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),

tsPanel.new('Rate of Received Packets')
+ tsPanel.standardOptions.withUnit('pps')
+ tsPanel.queryOptions.withTargets([
prometheus.new('${datasource}', 'sum(rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),

tsPanel.new('Rate of Transmitted Packets')
+ tsPanel.standardOptions.withUnit('pps')
+ tsPanel.queryOptions.withTargets([
prometheus.new('${datasource}', 'sum(rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_packets_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),

tsPanel.new('Rate of Received Packets Dropped')
+ tsPanel.standardOptions.withUnit('pps')
+ tsPanel.queryOptions.withTargets([
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)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_receive_packets_dropped_total{%(clusterLabel)s="$cluster",namespace!=""}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),

tsPanel.new('Rate of Transmitted Packets Dropped')
+ tsPanel.standardOptions.withUnit('pps')
+ tsPanel.queryOptions.withTargets([
prometheus.new('${datasource}', 'sum(rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s]) * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"}) by (pod)' % $._config)
prometheus.new(
'${datasource}', |||
sum by (pod) (
rate(container_network_transmit_packets_dropped_total{%(clusterLabel)s="$cluster",namespace=~"$namespace"}[%(grafanaIntervalVar)s])
* on (%(clusterLabel)s,namespace,pod) group_left ()
topk by (%(clusterLabel)s,namespace,pod) (
1,
max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"})
)
)
||| % $._config
)
+ prometheus.withLegendFormat('__auto'),
]),
];
Expand Down
Loading

0 comments on commit de92283

Please sign in to comment.