From 5ff527768493da69cb219d5c9c846400ad98850b Mon Sep 17 00:00:00 2001 From: Thomas Way Date: Fri, 5 Jan 2024 16:15:59 +0000 Subject: [PATCH] fix: match all non-idle cpu modes when calculating total cpu usage Fixes: #80 Fixes: #86 --- dashboards/k8s-views-global.json | 10 +++++----- dashboards/k8s-views-nodes.json | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dashboards/k8s-views-global.json b/dashboards/k8s-views-global.json index 1501f9b..4f687ec 100644 --- a/dashboards/k8s-views-global.json +++ b/dashboards/k8s-views-global.json @@ -150,7 +150,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "avg(1-rate(node_cpu_seconds_total{mode=\"idle\", cluster=\"$cluster\"}[$__rate_interval]))", + "expr": "avg(sum by (instance, cpu) (rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", cluster=\"$cluster\"}[$__rate_interval])))", "interval": "", "legendFormat": "Real", "range": true, @@ -701,7 +701,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "sum(1-rate(node_cpu_seconds_total{mode=\"idle\", cluster=\"$cluster\"}[$__rate_interval]))", + "expr": "sum(rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", cluster=\"$cluster\"}[$__rate_interval]))", "interval": "", "legendFormat": "Real", "range": true, @@ -1020,7 +1020,7 @@ "uid": "${datasource}" }, "exemplar": true, - "expr": "avg(1-rate(node_cpu_seconds_total{mode=\"idle\", cluster=\"$cluster\"}[$__rate_interval]))", + "expr": "avg(sum by (instance, cpu) (rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", cluster=\"$cluster\"}[$__rate_interval])))", "interval": "$resolution", "legendFormat": "CPU usage in %", "refId": "A" @@ -1435,7 +1435,7 @@ "uid": "${datasource}" }, "exemplar": true, - "expr": "avg(1-rate(node_cpu_seconds_total{mode=\"idle\", cluster=\"$cluster\"}[$__rate_interval])) by (instance)", + "expr": "avg(sum by (instance, cpu) (rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", cluster=\"$cluster\"}[$__rate_interval]))) by (instance)", "interval": "$resolution", "legendFormat": "{{ node }}", "refId": "A" @@ -2968,6 +2968,6 @@ "timezone": "", "title": "Kubernetes / Views / Global", "uid": "k8s_views_global", - "version": 34, + "version": 35, "weekStart": "" } diff --git a/dashboards/k8s-views-nodes.json b/dashboards/k8s-views-nodes.json index 839c88a..faaabf3 100644 --- a/dashboards/k8s-views-nodes.json +++ b/dashboards/k8s-views-nodes.json @@ -156,7 +156,7 @@ "uid": "${datasource}" }, "exemplar": false, - "expr": "avg(1-rate(node_cpu_seconds_total{mode=\"idle\", instance=\"$instance\", cluster=\"$cluster\"}[$__rate_interval]))", + "expr": "avg(sum by (cpu) (rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", instance=\"$instance\", cluster=\"$cluster\"}[$__rate_interval])))", "instant": true, "interval": "$resolution", "legendFormat": "", @@ -576,7 +576,7 @@ "uid": "${datasource}" }, "exemplar": false, - "expr": "sum(1-rate(node_cpu_seconds_total{mode=\"idle\", instance=\"$instance\", cluster=\"$cluster\"}[$__rate_interval]))", + "expr": "sum(rate(node_cpu_seconds_total{mode!~\"idle|iowait|steal\", instance=\"$instance\", cluster=\"$cluster\"}[$__rate_interval]))", "instant": true, "interval": "$resolution", "legendFormat": "", @@ -3933,6 +3933,6 @@ "timezone": "", "title": "Kubernetes / Views / Nodes", "uid": "k8s_views_nodes", - "version": 25, + "version": 26, "weekStart": "" }