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.
This commit is contained in:
Lance Walters 2026-10-27 01:36:02 -04:00
commit 28632e61c6
3 changed files with 30 additions and 27 deletions

View file

@ -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}]),