From 1db123c8146c517c0a1a7ef53ef28a671e9406be Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Mon, 10 Mar 2025 19:18:50 +0000
Subject: [PATCH] Add CPU throttling indicator

Add an indicator of whether the CPU has been throtting (usually due
to thermal constraints) to the host dashboard, overlaid on top of
the CPU usage graph as a red line.
---
 .../templates/grafana/dashboards/host.json    | 38 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/roles/float-infra-prometheus/templates/grafana/dashboards/host.json b/roles/float-infra-prometheus/templates/grafana/dashboards/host.json
index 71bbc26d..2eed1f18 100644
--- a/roles/float-infra-prometheus/templates/grafana/dashboards/host.json
+++ b/roles/float-infra-prometheus/templates/grafana/dashboards/host.json
@@ -132,6 +132,28 @@
                 }
               }
             ]
+          },
+          {
+            "matcher": {
+              "id": "byName",
+              "options": "throttle"
+            },
+            "properties": [
+              {
+                "id": "color",
+                "value": {
+                  "fixedColor": "red",
+                  "mode": "fixed"
+                }
+              },
+              {
+                "id": "custom.stacking",
+                "value": {
+                  "group": "A",
+                  "mode": "none"
+                }
+              }
+            ]
           }
         ]
       },
@@ -190,6 +212,20 @@
           "legendFormat": "{{mode}} ",
           "refId": "B",
           "step": 45
+        },
+        {
+          "datasource": {
+            "type": "prometheus",
+            "uid": "P49960DE5880E8C68"
+          },
+          "editorMode": "code",
+          "expr": "sum(irate(node_cpu_core_throttles_total{host=~\"$server\"}[$__rate_interval])) > bool 0 > 0",
+          "hide": false,
+          "instant": false,
+          "interval": "5m",
+          "legendFormat": "throttle",
+          "range": true,
+          "refId": "C"
         }
       ],
       "title": "CPU: utilization",
@@ -2853,4 +2889,4 @@
   "uid": "W8eE_Qgik",
   "version": 4,
   "weekStart": ""
-}
\ No newline at end of file
+}
-- 
GitLab