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.",
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).",
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)."),
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."),
desc="How long the oldest queued job has been waiting. Flat 0 = nothing queued."),
row("Runner pods",15),
ts("Runner pod restarts (24h)",[target('sum by (pod, container) (increase(kube_pod_container_status_restarts_total{%s}[24h]))'%RUN,"{{pod}} / {{container}}")],
{"h":8,"w":8,"x":0,"y":16},unit="short",
desc="increase() over 24h from kube-state-metrics. The history behind this board: the amd64 runner crashlooped on dind socket permissions."),
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."),
desc="Requested size of the forgejo-runner-amd64 PVC (docker data-root + named CI volumes). This is the ceiling, not the usage — see the note on this row."),
desc="The dind data-root lives on /opt/local-path-provisioner inside this filesystem, so this IS the number that caused the DiskPressure evictions at ~86%.",
stat("siriussec days to full",[target('clamp_max(node_filesystem_avail_bytes{%s} / clamp_min(-deriv(node_filesystem_avail_bytes{%s}[1h]), 0.0000001) / 86400, 365)'%(SIRIUSSEC_FS,SIRIUSSEC_FS))],
{"h":8,"w":4,"x":16,"y":25},unit="d",decimals=1,
desc="Linear projection from the last hour of free-space trend; 365 = not shrinking. Only meaningful after a few hours of history.",
desc="The arm64 runners run their jobs as HOST docker containers on rpi, so their writes land here, not in any PVC. node-exporter on rpi is what makes this visible."),
stat("Instances up",[target('min by (namespace) (cnpg_collector_up{%s})'%CLUSTER_NS)],
{"h":5,"w":4,"x":0,"y":1},desc="cnpg_collector_up from the instance manager (:9187) — 1 = PostgreSQL answering."),
stat("Nodes used / instances",[target('max by (namespace) (cnpg_collector_nodes_used{%s})'%CLUSTER_NS)],
{"h":5,"w":4,"x":4,"y":1},desc="1 with instances: 1 — no HA. Documented as a known limit, not a fault."),
stat("Connections used",[target('sum by (namespace) (cnpg_backends_total{%s})'%CLUSTER_NS)],
{"h":5,"w":4,"x":8,"y":1},desc="pg_stat_activity backends, all states."),
stat("Connections / max_connections",[target('100 * sum by (namespace) (cnpg_backends_total{%s}) / max by (namespace) (cnpg_pg_settings_setting{%s,name="max_connections"})'%(CLUSTER_NS,CLUSTER_NS))],
{"h":5,"w":4,"x":12,"y":1},unit="percent",
desc="Used against the server's own max_connections setting, so it stays right if the setting changes.",
stat("Last available backup",[target('max by (namespace) (cnpg_collector_last_available_backup_timestamp{%s})'%CLUSTER_NS)],
{"h":5,"w":4,"x":20,"y":1},unit="dateTimeAsIso",
desc="0 = never. There are NO Backup/Cluster backup resources in this cluster (verified: `kubectl get backups.postgresql.cnpg.io -A` is empty), so a 0 here is the honest answer, not a broken panel.",
desc="Commit / (commit + rollback). clamp_min keeps a quiet database from rendering NaN."),
ts("Cache hit ratio",[target('sum by (namespace) (rate(cnpg_pg_stat_database_blks_hit{%s}[5m])) / clamp_min(sum by (namespace) (rate(cnpg_pg_stat_database_blks_hit{%s}[5m])) + sum by (namespace) (rate(cnpg_pg_stat_database_blks_read{%s}[5m])), 0.0000001)'%(CLUSTER_NS,CLUSTER_NS,CLUSTER_NS),"{{namespace}}")],
{"h":8,"w":6,"x":18,"y":7},unit="percentunit",
desc="shared_buffers hit ratio. A lab database with 256Mi request will sit high; a drop means the working set outgrew the buffers."),
row("Errors and pressure",15),
ts("Deadlocks (24h increase)",[target('sum by (namespace) (increase(cnpg_pg_stat_database_deadlocks{%s}[24h]))'%CLUSTER_NS,"{{namespace}}")],
{"h":8,"w":8,"x":0,"y":16},unit="short",
desc="increase() on a counter that exists on every database, so a quiet DB renders a hard 0 rather than 'No data'."),
ts("Temp bytes/s",[target('sum by (namespace) (rate(cnpg_pg_stat_database_temp_bytes{%s}[5m]))'%CLUSTER_NS,"{{namespace}}")],
{"h":8,"w":8,"x":8,"y":16},unit="Bps",
desc="Spill to disk from sorts/hashes that did not fit work_mem. Non-zero during Forgejo Actions index scans is expected."),
ts("Longest transaction age",[target('max by (namespace) (cnpg_backends_max_tx_duration_seconds{%s})'%CLUSTER_NS,"{{namespace}}")],
{"h":8,"w":8,"x":16,"y":16},unit="s",
desc="Longest open transaction (pg_stat_activity.xact_start). The CNPG default query set exposes transaction age, not per-statement query age — see docs."),
row("Size, WAL, replication",24),
ts("Database size",[target('max by (namespace, datname) (cnpg_pg_database_size_bytes{%s,datname!~"template.*|postgres"})'%CLUSTER_NS,"{{namespace}}/{{datname}}")],
{"h":8,"w":8,"x":0,"y":25},unit="bytes",
desc="pg_database_size. Both PVs are 10Gi (forgejo/pg) and 5Gi (sirius-growth/portal) — this is the trend that fills them."),
ts("WAL generation",[target('sum by (namespace) (rate(cnpg_collector_wal_bytes{%s}[5m]))'%CLUSTER_NS,"{{namespace}}")],
{"h":8,"w":8,"x":8,"y":25},unit="Bps",
desc="Bytes of WAL written per second. On a cluster with no backups, WAL has nothing archiving it away."),
ts("WAL archiver failures",[target('max by (namespace) (cnpg_pg_stat_archiver_failed_count{%s})'%CLUSTER_NS,"{{namespace}}")],
{"h":8,"w":8,"x":16,"y":25},unit="short",
desc="pg_stat_archiver.failed_count. Archiving is not configured on either cluster (no ObjectStore/backup), so treat non-zero here as 'something was attempted and failed'."),
row("Replication (single instance — panels are honest about it)",33),
ts("Replication lag",[target('max by (namespace) (cnpg_pg_replication_lag{%s})'%CLUSTER_NS,"{{namespace}}")],
{"h":6,"w":8,"x":0,"y":34},unit="s",
desc="0 on the primary with no standby. With instances: 1 this metric is structurally zero, not evidence that replication is healthy."),
ts("Streaming replicas / in recovery",[target('max by (namespace) (cnpg_pg_replication_streaming_replicas{%s})'%CLUSTER_NS,"{{namespace}} streaming"),
target('max by (namespace) (cnpg_pg_replication_in_recovery{%s})'%CLUSTER_NS,"{{namespace}} in recovery",ref="B")],
{"h":6,"w":8,"x":8,"y":34},unit="short",
desc="Both clusters run instances: 1, so 0 streaming replicas and in_recovery=0 is the correct reading. A future replica would light these up with no dashboard change."),
desc="blackbox-exporter probes of http://10.10.0.2:8081/ and :8084/ (monitoring/controllers/home/gateway-probe.yaml). 2 = both internal services answering.",
desc="Sum of every PVC request (local-path: all on siriussec's disk). Usage per PV is not available — see the note at the bottom."),
row("Requests vs usage",6),
ts("CPU usage by namespace",[target('sum by (namespace) (rate(container_cpu_usage_seconds_total{container!=""}[5m]))',"{{namespace}}")],
{"h":8,"w":12,"x":0,"y":7},unit="cores",
desc="cAdvisor, all containers including pause-less init containers. Compare with the requests panel next to it."),
ts("CPU requests by namespace",[target('sum by (namespace) (kube_pod_container_resource_requests{resource="cpu"})',"{{namespace}}")],
{"h":8,"w":12,"x":12,"y":7},unit="cores",
desc="Scheduler-visible requests — this is what makes a pod Pending, not usage."),
ts("Memory usage by namespace",[target('sum by (namespace) (container_memory_working_set_bytes{container!=""})',"{{namespace}}")],
{"h":8,"w":12,"x":0,"y":15},unit="bytes"),
ts("Memory requests by namespace",[target('sum by (namespace) (kube_pod_container_resource_requests{resource="memory"})',"{{namespace}}")],
{"h":8,"w":12,"x":12,"y":15},unit="bytes"),
row("Top pods",23),
ts("Top 10 pods by CPU",[target('topk(10, sum by (namespace, pod) (rate(container_cpu_usage_seconds_total{container!=""}[5m])))',"{{namespace}}/{{pod}}")],
{"h":8,"w":12,"x":0,"y":24},unit="cores"),
ts("Top 10 pods by memory",[target('topk(10, sum by (namespace, pod) (container_memory_working_set_bytes{container!=""}))',"{{namespace}}/{{pod}}")],
{"h":8,"w":12,"x":12,"y":24},unit="bytes"),
ts("Pod restarts (24h, top 10)",[target('topk(10, sum by (namespace, pod) (increase(kube_pod_container_status_restarts_total[24h])))',"{{namespace}}/{{pod}}")],
{"h":8,"w":12,"x":0,"y":32},unit="short",
desc="increase() over 24h. Values below 1 are container restarts that happened before the current scrape window started."),
desc="1 = HTTP 2xx/3xx from blackbox-exporter every 30s. There is no Alertmanager in this stack, so this panel and Prometheus /alerts are the alerting surface."),
row("Nodes",40),
ts("Node CPU utilisation",[target('100 * (1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])))',"{{instance}}")],