From 28632e61c69e28e00ec1026ba94c5f3f2ef3daab Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 27 Oct 2026 01:36:02 -0400 Subject: [PATCH] dashboards: fix runner pod selector and custom-metric labels after panel validation Panel validation against the live Prometheus API caught three real faults: - pod=~"forgejo-runner-.*" also matched the forgejo-runner-prune-* CronJob pods, which are Completed and permanently not-Ready, so the not-Ready stat read 3. - CNPG custom-query metrics carry namespace/pod from the scrape, not the exporter's cluster label, so cluster="pg" matched nothing (empty panels). - a missing paren in the memory-working-set expression (HTTP 400 from Prometheus). Also make two legitimately-empty stats render a hard 0 (or vector(0)) instead of 'No data': not-Ready runner pods, and nodes with DiskPressure. 55/55 panel targets now return non-empty results. --- .../controllers/home/dashboards/build.py | 27 ++++++++++-------- .../home/dashboards/forgejo-runners.yaml | 28 +++++++++---------- .../home/dashboards/home-lab-workloads.yaml | 2 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/monitoring/controllers/home/dashboards/build.py b/monitoring/controllers/home/dashboards/build.py index 7a69f1b..2c937aa 100644 --- a/monitoring/controllers/home/dashboards/build.py +++ b/monitoring/controllers/home/dashboards/build.py @@ -131,7 +131,10 @@ def ns_variable(): # ---------------------------------------------------------------- runners ----- -RUN = 'namespace="forgejo",pod=~"forgejo-runner-.*"' +# Only the three runner Deployments' pods. `forgejo-runner-.*` also matches the +# `forgejo-runner-prune-*` CronJob pods, which are Completed and permanently +# "not Ready" — that turned a 0 into a 3 on the not-Ready stat. +RUN = 'namespace="forgejo",pod=~"forgejo-runner-(amd64|arm64|deploy-arm64)-.*"' SIRIUSSEC_FS = 'instance="10.10.0.2:9100",mountpoint="/"' RPI_FS = 'instance="10.10.0.1:9100",mountpoint="/"' @@ -140,37 +143,37 @@ runners = [ stat("Runner pods Ready", [target('sum(kube_deployment_status_replicas_ready{namespace="forgejo",deployment=~"forgejo-runner-.*"})')], {"h": 5, "w": 4, "x": 0, "y": 1}, desc="replicas_ready summed across the three runner Deployments. Expected 3.", thresholds=[{"color": "red", "value": None}, {"color": "yellow", "value": 2}, {"color": "green", "value": 3}]), - stat("Runner pods not Ready", [target('sum(kube_pod_status_ready{%s,condition="false"} == 1)' % RUN)], + stat("Runner pods not Ready", [target('sum(kube_pod_status_ready{%s,condition="false"} == 1) or vector(0)' % RUN)], {"h": 5, "w": 4, "x": 4, "y": 1}, desc="Running-but-not-Ready runner pods (crashloop, failing probe).", thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}], reducer="lastNotNull"), - stat("Last runner poll age", [target('max(cnpg_actions_runners_last_online_seconds{cluster="pg"})')], + stat("Last runner poll age", [target('max(cnpg_actions_runners_last_online_seconds{namespace="forgejo"})')], {"h": 5, "w": 4, "x": 8, "y": 1}, unit="s", desc="Worst of the three runners, from Forgejo's action_runner.last_online. A Running pod whose poll age climbs is a runner that cannot reach the forge.", thresholds=[{"color": "green", "value": None}, {"color": "yellow", "value": 90}, {"color": "red", "value": 300}]), - stat("Queue depth", [target('max(cnpg_actions_queue_depth{cluster="pg"})')], + stat("Queue depth", [target('max(cnpg_actions_queue_depth{namespace="forgejo"})')], {"h": 5, "w": 4, "x": 12, "y": 1}, desc="Jobs assigned to a runner that have not started (action_run_job: started=0, stopped=0, status<>4).", thresholds=[{"color": "green", "value": None}, {"color": "yellow", "value": 1}, {"color": "red", "value": 3}]), - stat("Running now", [target('max(cnpg_actions_running_total{cluster="pg"})')], + stat("Running now", [target('max(cnpg_actions_running_total{namespace="forgejo"})')], {"h": 5, "w": 4, "x": 16, "y": 1}, desc="Jobs currently executing. capacity=1 per runner, so >3 here means something is stuck."), - stat("Queue while running = contention", [target('max((cnpg_actions_queue_depth{cluster="pg"} > bool 0) * (cnpg_actions_running_total{cluster="pg"} > bool 0))')], + stat("Queue while running = contention", [target('max((cnpg_actions_queue_depth{namespace="forgejo"} > bool 0) * (cnpg_actions_running_total{namespace="forgejo"} > bool 0))')], {"h": 5, "w": 4, "x": 20, "y": 1}, desc="1 = jobs are queued while another job runs, i.e. the single-slot runners are the bottleneck (this is why capacity stays 1: two concurrent jobs clobbered the shared docker volumes).", thresholds=[{"color": "green", "value": None}, {"color": "orange", "value": 1}]), row("Action throughput & outcomes", 6), ts("Jobs finished, by status (24h window)", - [target('cnpg_actions_jobs_window_total{cluster="pg",window="24h"}', "status {{status}}")], + [target('cnpg_actions_jobs_window_total{namespace="forgejo",window="24h"}', "status {{status}}")], {"h": 8, "w": 8, "x": 0, "y": 7}, unit="short", desc="Rolling 24h count of action_run_job rows with stopped in the window. status 1=success 2=failure 3=cancelled 4=skipped (codes validated against /api/v1 .../actions/runs)."), ts("Successes / hour and failures / hour", - [target('max(cnpg_actions_jobs_window_total{cluster="pg",window="1h",status="1"})', "success, last 60m"), - target('max(cnpg_actions_jobs_window_total{cluster="pg",window="1h",status="2"})', "failure, last 60m", ref="B")], + [target('max(cnpg_actions_jobs_window_total{namespace="forgejo",window="1h",status="1"})', "success, last 60m"), + target('max(cnpg_actions_jobs_window_total{namespace="forgejo",window="1h",status="2"})', "failure, last 60m", ref="B")], {"h": 8, "w": 8, "x": 8, "y": 7}, unit="short", desc="Jobs that finished inside the last rolling hour. A true rolling count, not rate() over a row count — Forgejo prunes rows, so rate() would drift."), ts("Oldest not-yet-started job age", - [target('cnpg_actions_queue_oldest_pending_seconds{cluster="pg"}')], + [target('cnpg_actions_queue_oldest_pending_seconds{namespace="forgejo"}')], {"h": 8, "w": 8, "x": 16, "y": 7}, unit="s", desc="How long the oldest queued job has been waiting. Flat 0 = nothing queued."), @@ -181,7 +184,7 @@ runners = [ ts("CPU usage per runner pod", [target('sum by (pod) (rate(container_cpu_usage_seconds_total{%s,container!=""}[5m]))' % RUN, "{{pod}}")], {"h": 8, "w": 8, "x": 8, "y": 16}, unit="cores", desc="cAdvisor CPU per runner pod. The dind sidecar of forgejo-runner-amd64 does the actual build work."), - ts("Memory working set per runner pod", [target('sum by (pod) (container_memory_working_set_bytes{%s,container!=""}' % RUN, "{{pod}}")], + ts("Memory working set per runner pod", [target('sum by (pod) (container_memory_working_set_bytes{%s,container!=""})' % RUN, "{{pod}}")], {"h": 8, "w": 8, "x": 16, "y": 16}, unit="bytes", desc="cAdvisor working set. Note the amd64 runner's dind keeps a 1Gi memory limit — a build that OOMs shows here first."), @@ -308,7 +311,7 @@ workloads = [ row("Cluster", 0), stat("Nodes Ready", [target('count(kube_node_status_condition{condition="Ready",status="true"} == 1)')], {"h": 5, "w": 4, "x": 0, "y": 1}, thresholds=[{"color": "red", "value": None}, {"color": "yellow", "value": 2}, {"color": "green", "value": 3}]), - stat("Nodes with DiskPressure", [target('sum(kube_node_status_condition{condition="DiskPressure",status="true"} == 1)')], + stat("Nodes with DiskPressure", [target('sum(kube_node_status_condition{condition="DiskPressure",status="true"} == 1) or vector(0)')], {"h": 5, "w": 4, "x": 4, "y": 1}, desc="The taint that evicted Forgejo and pg-1 in the past. >0 here is an incident, not a warning.", thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}]), diff --git a/monitoring/controllers/home/dashboards/forgejo-runners.yaml b/monitoring/controllers/home/dashboards/forgejo-runners.yaml index 9729114..8932e12 100644 --- a/monitoring/controllers/home/dashboards/forgejo-runners.yaml +++ b/monitoring/controllers/home/dashboards/forgejo-runners.yaml @@ -156,7 +156,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum(kube_pod_status_ready{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\",condition=\"false\"} == 1)", + "expr": "sum(kube_pod_status_ready{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",condition=\"false\"} == 1) or vector(0)", "refId": "A", "editorMode": "code", "range": true, @@ -220,7 +220,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max(cnpg_actions_runners_last_online_seconds{cluster=\"pg\"})", + "expr": "max(cnpg_actions_runners_last_online_seconds{namespace=\"forgejo\"})", "refId": "A", "editorMode": "code", "range": true, @@ -289,7 +289,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max(cnpg_actions_queue_depth{cluster=\"pg\"})", + "expr": "max(cnpg_actions_queue_depth{namespace=\"forgejo\"})", "refId": "A", "editorMode": "code", "range": true, @@ -357,7 +357,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max(cnpg_actions_running_total{cluster=\"pg\"})", + "expr": "max(cnpg_actions_running_total{namespace=\"forgejo\"})", "refId": "A", "editorMode": "code", "range": true, @@ -421,7 +421,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max((cnpg_actions_queue_depth{cluster=\"pg\"} > bool 0) * (cnpg_actions_running_total{cluster=\"pg\"} > bool 0))", + "expr": "max((cnpg_actions_queue_depth{namespace=\"forgejo\"} > bool 0) * (cnpg_actions_running_total{namespace=\"forgejo\"} > bool 0))", "refId": "A", "editorMode": "code", "range": true, @@ -498,7 +498,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "cnpg_actions_jobs_window_total{cluster=\"pg\",window=\"24h\"}", + "expr": "cnpg_actions_jobs_window_total{namespace=\"forgejo\",window=\"24h\"}", "refId": "A", "editorMode": "code", "range": true, @@ -555,7 +555,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max(cnpg_actions_jobs_window_total{cluster=\"pg\",window=\"1h\",status=\"1\"})", + "expr": "max(cnpg_actions_jobs_window_total{namespace=\"forgejo\",window=\"1h\",status=\"1\"})", "refId": "A", "editorMode": "code", "range": true, @@ -567,7 +567,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "max(cnpg_actions_jobs_window_total{cluster=\"pg\",window=\"1h\",status=\"2\"})", + "expr": "max(cnpg_actions_jobs_window_total{namespace=\"forgejo\",window=\"1h\",status=\"2\"})", "refId": "B", "editorMode": "code", "range": true, @@ -624,7 +624,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "cnpg_actions_queue_oldest_pending_seconds{cluster=\"pg\"}", + "expr": "cnpg_actions_queue_oldest_pending_seconds{namespace=\"forgejo\"}", "refId": "A", "editorMode": "code", "range": true, @@ -693,7 +693,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum by (pod, container) (increase(kube_pod_container_status_restarts_total{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\"}[24h]))", + "expr": "sum by (pod, container) (increase(kube_pod_container_status_restarts_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[24h]))", "refId": "A", "editorMode": "code", "range": true, @@ -750,7 +750,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\",container!=\"\"}[5m]))", + "expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"}[5m]))", "refId": "A", "editorMode": "code", "range": true, @@ -807,7 +807,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum by (pod) (container_memory_working_set_bytes{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\",container!=\"\"}", + "expr": "sum by (pod) (container_memory_working_set_bytes{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\",container!=\"\"})", "refId": "A", "editorMode": "code", "range": true, @@ -877,7 +877,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum by (pod) (rate(container_network_receive_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\"}[5m]))", + "expr": "sum by (pod) (rate(container_network_receive_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))", "refId": "A", "editorMode": "code", "range": true, @@ -889,7 +889,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum by (pod) (rate(container_network_transmit_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-.*\"}[5m]))", + "expr": "sum by (pod) (rate(container_network_transmit_bytes_total{namespace=\"forgejo\",pod=~\"forgejo-runner-(amd64|arm64|deploy-arm64)-.*\"}[5m]))", "refId": "B", "editorMode": "code", "range": true, diff --git a/monitoring/controllers/home/dashboards/home-lab-workloads.yaml b/monitoring/controllers/home/dashboards/home-lab-workloads.yaml index 1041106..07674d9 100644 --- a/monitoring/controllers/home/dashboards/home-lab-workloads.yaml +++ b/monitoring/controllers/home/dashboards/home-lab-workloads.yaml @@ -155,7 +155,7 @@ data: "type": "prometheus", "uid": "prometheus" }, - "expr": "sum(kube_node_status_condition{condition=\"DiskPressure\",status=\"true\"} == 1)", + "expr": "sum(kube_node_status_condition{condition=\"DiskPressure\",status=\"true\"} == 1) or vector(0)", "refId": "A", "editorMode": "code", "range": true,