From 19ccf930858e4db9b18479532450383e40d56897 Mon Sep 17 00:00:00 2001 From: Pinghao Wu Date: Mon, 20 Jan 2025 21:02:55 +0800 Subject: [PATCH] grafana: kubernetes-containers: handle crashloop better --- monitoring/grafana/kubernetes-containers.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/monitoring/grafana/kubernetes-containers.yaml b/monitoring/grafana/kubernetes-containers.yaml index c9455bb..1bd5ad4 100644 --- a/monitoring/grafana/kubernetes-containers.yaml +++ b/monitoring/grafana/kubernetes-containers.yaml @@ -27,7 +27,7 @@ spec: datasource='$DS_PROMETHEUS', ).addTarget( grafana.prometheus.target( - 'label_replace(rate(container_cpu_usage_seconds_total{' + matchers + '}[$__rate_interval]), "host", "$1", "instance", "([^.]*).*:10250")', + 'label_replace(sum by (namespace, pod, container, instance) (rate(container_cpu_usage_seconds_total{' + matchers + '}[$__rate_interval])), "host", "$1", "instance", "([^.]*).*:10250")', legendFormat='{{pod}}/{{container}}@{{host}}', ) ), @@ -40,7 +40,7 @@ spec: format='bytes', ).addTarget( grafana.prometheus.target( - 'container_memory_usage_bytes{' + matchers + '}', + 'sum by (namespace, pod, container) (container_memory_usage_bytes{' + matchers + '})', legendFormat='{{pod}}/{{container}}', ) ), @@ -53,7 +53,7 @@ spec: format='bytes', ).addTarget( grafana.prometheus.target( - 'container_memory_rss{' + matchers + '}', + 'sum by (namespace, pod, container) (container_memory_rss{' + matchers + '})', legendFormat='{{pod}}/{{container}}', ) ), @@ -66,7 +66,7 @@ spec: format='bytes', ).addTarget( grafana.prometheus.target( - 'container_memory_cache{' + matchers + '}', + 'sum by (namespace, pod, container) (container_memory_cache{' + matchers + '})', legendFormat='{{pod}}/{{container}}', ) ), @@ -79,7 +79,7 @@ spec: format='Bps', ).addTarget( grafana.prometheus.target( - 'rate(container_network_receive_bytes_total{interface="eth0", ' + podMatchers + '}[$__rate_interval])', + 'sum by (namespace, pod, container) (rate(container_network_receive_bytes_total{interface="eth0", ' + podMatchers + '}[$__rate_interval]))', legendFormat='{{pod}}', ) ), @@ -92,7 +92,7 @@ spec: format='Bps', ).addTarget( grafana.prometheus.target( - 'rate(container_network_transmit_bytes_total{interface="eth0", ' + podMatchers + '}[$__rate_interval])', + 'sum by (namespace, pod, container) (rate(container_network_transmit_bytes_total{interface="eth0", ' + podMatchers + '}[$__rate_interval]))', legendFormat='{{pod}}', ) ), -- 2.45.2