From 2ea98c7df9d19ef5fb6517159606b1415d6f05e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 26 Jul 2024 10:58:59 +0200 Subject: [PATCH 1/3] fix: Error "multiple matches for labels: many-to-one matching must be explicit (group_left/group_right)" on Kubernetes/Networking Dashboards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- .../network-usage/cluster-total.libsonnet | 204 +++++++++++++++--- 1 file changed, 180 insertions(+), 24 deletions(-) diff --git a/dashboards/network-usage/cluster-total.libsonnet b/dashboards/network-usage/cluster-total.libsonnet index 3bcfe1d28..14f6941ff 100644 --- a/dashboards/network-usage/cluster-total.libsonnet +++ b/dashboards/network-usage/cluster-total.libsonnet @@ -66,8 +66,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + sum by (namespace) ( + rate(container_network_receive_bytes_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'), ]), @@ -76,8 +84,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_bytes_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'), ]), @@ -85,35 +101,107 @@ local var = g.dashboard.variable; table.new('Current Status') + table.gridPos.withW(24) + table.queryOptions.withTargets([ - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_receive_bytes_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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_bytes_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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + avg by (namespace) ( + rate(container_network_receive_bytes_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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + avg by (namespace) ( + rate(container_network_transmit_bytes_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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_receive_packets_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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_packets_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.withInstant(true) + prometheus.withFormat('table'), - 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 (namespace) ( + 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.withInstant(true) + prometheus.withFormat('table'), - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_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.withInstant(true) + prometheus.withFormat('table'), ]) @@ -213,8 +301,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + avg by (namespace) ( + rate(container_network_receive_bytes_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'), ]), @@ -223,8 +319,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + avg by (namespace) ( + rate(container_network_transmit_bytes_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'), ]), @@ -233,8 +337,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + sum by (namespace) ( + rate(container_network_receive_bytes_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'), ]), @@ -243,8 +355,16 @@ local var = g.dashboard.variable; + tsPanel.standardOptions.withUnit('binBps') + tsPanel.queryOptions.withTargets([ 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 + '${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_bytes_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'), ]), @@ -252,28 +372,64 @@ local var = g.dashboard.variable; tsPanel.new('Rate of Received Packets') + tsPanel.standardOptions.withUnit('pps') + tsPanel.queryOptions.withTargets([ - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_receive_packets_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') + tsPanel.standardOptions.withUnit('pps') + tsPanel.queryOptions.withTargets([ - 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_packets_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 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 (namespace) ( + 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 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) + prometheus.new('${datasource}', ||| + sum by (namespace) ( + rate(container_network_transmit_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'), ]), From de92283717b4d3c0e0a3c23822967a94f986aad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Tue, 6 Aug 2024 23:55:29 +0200 Subject: [PATCH 2/3] fix: Error "multiple matches for labels: many-to-one matching must be explicit (group_left/group_right)" on Kubernetes/Networking Dashboards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- .../network-usage/cluster-total.libsonnet | 26 ++- .../network-usage/namespace-by-pod.libsonnet | 172 ++++++++++++++++-- .../namespace-by-workload.libsonnet | 60 +++++- 3 files changed, 228 insertions(+), 30 deletions(-) diff --git a/dashboards/network-usage/cluster-total.libsonnet b/dashboards/network-usage/cluster-total.libsonnet index 14f6941ff..78835685b 100644 --- a/dashboards/network-usage/cluster-total.libsonnet +++ b/dashboards/network-usage/cluster-total.libsonnet @@ -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'), ]), ]; diff --git a/dashboards/network-usage/namespace-by-pod.libsonnet b/dashboards/network-usage/namespace-by-pod.libsonnet index 9f36ee1ea..2a5843767 100644 --- a/dashboards/network-usage/namespace-by-pod.libsonnet +++ b/dashboards/network-usage/namespace-by-pod.libsonnet @@ -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'), ]), @@ -132,8 +140,16 @@ 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'), ]), @@ -141,27 +157,87 @@ local var = g.dashboard.variable; 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'), ]) @@ -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'), ]), @@ -264,8 +348,16 @@ 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'), ]), @@ -273,28 +365,72 @@ local var = g.dashboard.variable; 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'), ]), ]; diff --git a/dashboards/network-usage/namespace-by-workload.libsonnet b/dashboards/network-usage/namespace-by-workload.libsonnet index c3a5af37f..2d12a845f 100644 --- a/dashboards/network-usage/namespace-by-workload.libsonnet +++ b/dashboards/network-usage/namespace-by-workload.libsonnet @@ -155,7 +155,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -174,7 +178,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -325,7 +333,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -340,7 +352,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -355,7 +371,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(avg(rate(container_network_receive_bytes_total{%(clusterLabel)s="$cluster",namespace="$namespace"}[%(grafanaIntervalVar)s]) - * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -370,7 +390,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(avg(rate(container_network_transmit_bytes_total{%(clusterLabel)s="$cluster",namespace="$namespace"}[%(grafanaIntervalVar)s]) - * on (%(clusterLabel)s,namespace,pod) kube_pod_info{host_network="false"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -385,7 +409,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -400,7 +428,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -415,7 +447,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config @@ -430,7 +466,11 @@ local var = g.dashboard.variable; '${datasource}', ||| sort_desc(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"} + * 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"}) + ) * on (%(clusterLabel)s,namespace,pod) group_left(workload,workload_type) namespace_workload_pod:kube_pod_owner:relabel{%(clusterLabel)s="$cluster",namespace="$namespace", workload=~".+", workload_type=~"$type"}) by (workload)) ||| % $._config From 34dae8c9bb57d78d707317844da574f5c604df15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Wed, 7 Aug 2024 00:05:06 +0200 Subject: [PATCH 3/3] make fmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- .../network-usage/namespace-by-pod.libsonnet | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dashboards/network-usage/namespace-by-pod.libsonnet b/dashboards/network-usage/namespace-by-pod.libsonnet index 2a5843767..662d46251 100644 --- a/dashboards/network-usage/namespace-by-pod.libsonnet +++ b/dashboards/network-usage/namespace-by-pod.libsonnet @@ -149,7 +149,7 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config + ||| % $._config ) + prometheus.withLegendFormat('__auto'), ]), @@ -167,7 +167,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), @@ -181,7 +182,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), @@ -195,7 +197,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), @@ -209,7 +212,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), @@ -223,7 +227,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), @@ -237,7 +242,8 @@ local var = g.dashboard.variable; max by (%(clusterLabel)s,namespace,pod) (kube_pod_info{host_network="false"}) ) ) - ||| % $._config) + ||| % $._config + ) + prometheus.withInstant(true) + prometheus.withFormat('table'), ])