2026-10-27 01:32:20 -04:00
#!/usr/bin/env python3
""" Build the three homelab Grafana dashboards as provisioned ConfigMaps.
Emits monitoring / controllers / home / dashboards / * . yaml in ~ / Projects / homek8s .
The JSON dashboard lives inside the ConfigMap under a ` . json ` key , which is what
the kube - prometheus - stack grafana dashboard sidecar ( LABEL = grafana_dashboard ,
LABEL_VALUE = 1 , NAMESPACE = ALL ) mounts .
Kept as a script so panel edits are reviewable and the validation step
( validate_panels . py ) can re - read the same JSON from the emitted YAML .
"""
import json
import os
import sys
OUT_DIR = sys . argv [ 1 ] if len ( sys . argv ) > 1 else os . path . expanduser (
" ~/Projects/homek8s/monitoring/controllers/home/dashboards " )
DS = { " type " : " prometheus " , " uid " : " prometheus " }
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
# Loki is provisioned by infrastructure/logging/datasource.yaml with a pinned
# uid, so panels can reference it without a lookup.
DS_LOKI = { " type " : " loki " , " uid " : " loki " }
2026-10-27 01:32:20 -04:00
CLUSTER_NS = ' namespace=~ " $namespace " '
_next_id = [ 0 ]
def pid ( ) :
_next_id [ 0 ] + = 1
return _next_id [ 0 ]
def target ( expr , legend = None , ref = " A " , instant = False , fmt = " time_series " ) :
t = { " datasource " : DS , " expr " : expr , " refId " : ref ,
" editorMode " : " code " , " range " : not instant , " instant " : instant }
if legend :
t [ " legendFormat " ] = legend
return t
def ts ( title , targets , grid , unit = None , desc = " " , stack = False , fill = 0 , overrides = None ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
w = 12 , h = 8 , ds = DS ) :
2026-10-27 01:32:20 -04:00
p = {
" id " : pid ( ) , " type " : " timeseries " , " title " : title , " description " : desc ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
" datasource " : ds , " gridPos " : grid , " targets " : targets ,
2026-10-27 01:32:20 -04:00
" fieldConfig " : { " defaults " : { " custom " : { " lineWidth " : 1 , " fillOpacity " : fill ,
" showPoints " : " never " } ,
" color " : { " mode " : " palette-classic " } } ,
" overrides " : overrides or [ ] } ,
" options " : { " legend " : { " displayMode " : " list " , " placement " : " bottom " ,
" calcs " : [ " lastNotNull " ] } ,
" tooltip " : { " mode " : " multi " , " sort " : " desc " } } ,
}
if unit :
p [ " fieldConfig " ] [ " defaults " ] [ " unit " ] = unit
if stack :
p [ " fieldConfig " ] [ " defaults " ] [ " custom " ] [ " stacking " ] = { " mode " : " normal " }
return p
def stat ( title , targets , grid , unit = None , desc = " " , text_size = 32 , reducer = " lastNotNull " ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
thresholds = None , w = 4 , h = 5 , decimals = None , ds = DS ) :
2026-10-27 01:32:20 -04:00
p = {
" id " : pid ( ) , " type " : " stat " , " title " : title , " description " : desc ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
" datasource " : ds , " gridPos " : grid , " targets " : targets ,
2026-10-27 01:32:20 -04:00
" fieldConfig " : { " defaults " : {
" color " : { " mode " : " thresholds " } ,
" mappings " : [ ] ,
" thresholds " : { " mode " : " absolute " , " steps " : thresholds or [
{ " color " : " red " , " value " : None } ,
{ " color " : " green " , " value " : 1 } ] } ,
} , " overrides " : [ ] } ,
" options " : { " colorMode " : " value " , " graphMode " : " area " ,
" reduceOptions " : { " calcs " : [ reducer ] , " fields " : " " , " values " : False } ,
" textMode " : " auto " , " justifyMode " : " auto " } ,
}
if unit :
p [ " fieldConfig " ] [ " defaults " ] [ " unit " ] = unit
if decimals is not None :
p [ " fieldConfig " ] [ " defaults " ] [ " decimals " ] = decimals
return p
def bargauge ( title , targets , grid , unit = None , desc = " " , w = 8 , h = 8 ) :
return {
" id " : pid ( ) , " type " : " bargauge " , " title " : title , " description " : desc ,
" datasource " : DS , " gridPos " : grid , " targets " : targets ,
" fieldConfig " : { " defaults " : { " unit " : unit or " short " , " min " : 0 ,
" color " : { " mode " : " palette-classic " } ,
" mappings " : [ ] } , " overrides " : [ ] } ,
" options " : { " displayMode " : " gradient " , " orientation " : " horizontal " ,
" reduceOptions " : { " calcs " : [ " lastNotNull " ] , " fields " : " " , " values " : False } ,
" showUnfilled " : True , " valueMode " : " color " } ,
}
def note ( title , md , grid , h = 6 ) :
return {
" id " : pid ( ) , " type " : " text " , " title " : title , " gridPos " : grid ,
" options " : { " mode " : " markdown " , " code " : { " language " : " plaintext " , " showLineNumbers " : False ,
" showMiniMap " : False } ,
" content " : md } ,
}
def row ( title , y ) :
return { " id " : pid ( ) , " type " : " row " , " title " : title , " collapsed " : False ,
" gridPos " : { " h " : 1 , " w " : 24 , " x " : 0 , " y " : y } , " panels " : [ ] }
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
# ---------------------------------------------------------------- logs --------
# Loki targets. NOTE the field names are the audit pipeline's, not the raw
# kube-apiserver audit-event ones: infrastructure/logging/alloy/config.alloy
# re-emits each record as a flat allowlist, so `objectRef.resource` arrives as
# the stream label `resource` and `user.username` as `user`. `| json` is only
# needed to reach `user`/`ns`/`name`; the resource filter stays in the selector
# as a label matcher so Loki prunes streams before parsing anything.
AUDIT_SECRETS = ' { job= " kube/apiserver-audit " , resource= " secrets " } '
POD_LOGS = ' { job= " kube/pods " } '
POD_SEL = ' job= " kube/pods " '
RUNNER_NS = ' namespace=~ " $runner_ns " '
def loki_target ( expr , legend = None , ref = " A " , instant = False ) :
t = { " datasource " : DS_LOKI , " expr " : expr , " refId " : ref ,
" queryType " : " instant " if instant else " range " ,
" range " : not instant , " instant " : instant }
if legend :
t [ " legendFormat " ] = legend
return t
def logs ( title , targets , grid , desc = " " , sort = " Descending " ) :
return {
" id " : pid ( ) , " type " : " logs " , " title " : title , " description " : desc ,
" datasource " : DS_LOKI , " gridPos " : grid , " targets " : targets ,
" options " : { " showTime " : True , " showLabels " : False , " showCommonLabels " : False ,
" wrapLogMessage " : True , " prettifyLogMessage " : False ,
" enableLogDetails " : True , " dedupStrategy " : " none " ,
" sortOrder " : sort } ,
}
2026-10-27 01:32:20 -04:00
def dashboard ( uid , title , tags , panels , description , variables = None ) :
return {
" uid " : uid , " title " : title , " description " : description , " tags " : tags ,
" timezone " : " browser " , " editable " : True , " graphTooltip " : 1 ,
" schemaVersion " : 39 , " version " : 1 , " refresh " : " 30s " ,
" time " : { " from " : " now-6h " , " to " : " now " } ,
" annotations " : { " list " : [ { " builtIn " : 1 , " datasource " : { " type " : " grafana " , " uid " : " -- Grafana -- " } ,
" enable " : True , " hide " : True , " iconColor " : " rgba(0, 211, 255, 1) " ,
" name " : " Annotations & Alerts " , " type " : " dashboard " } ] } ,
" links " : [ ] ,
" templating " : { " list " : variables or [ ] } ,
" panels " : panels ,
}
def ns_variable ( ) :
return {
" name " : " namespace " , " label " : " Postgres cluster (namespace) " , " type " : " query " ,
" datasource " : DS , " refresh " : 1 , " includeAll " : True , " multi " : True ,
" allValue " : " .* " , " current " : { " selected " : True , " text " : [ " All " ] , " value " : [ " $__all " ] } ,
" options " : [ ] ,
" query " : { " query " : " label_values(cnpg_collector_up, namespace) " , " refId " : " PromQLNamespace " } ,
}
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
def loki_ns_variable ( ) :
# Same "All = .*" contract as ns_variable, but the option list comes from
# Loki's label API so it also contains namespaces Prometheus never scrapes
# (ci-probe, metabase, ...) and does not need kube-state-metrics.
return {
" name " : " namespace " , " label " : " Namespace " , " type " : " query " ,
" datasource " : DS_LOKI , " refresh " : 2 , " includeAll " : True , " multi " : True ,
" allValue " : " .* " , " current " : { " selected " : True , " text " : [ " All " ] , " value " : [ " $__all " ] } ,
" options " : [ ] ,
" query " : { " query " : ' label_values( %s , namespace) ' % POD_LOGS , " refId " : " LokiNamespace " } ,
}
def loki_runner_ns_variable ( ) :
# Runner namespaces are being moved by t_2bbe34a8 (forgejo -> forgejo-runners,
# with ci-runners also live), so the panels discover them instead of pinning
# one name: "All" expands to a regex that matches any *runner* namespace plus
# forgejo itself (which still runs pods the runners need to be read next to).
return {
" name " : " runner_ns " , " label " : " Runner namespace " , " type " : " query " ,
" datasource " : DS_LOKI , " refresh " : 2 , " includeAll " : True , " multi " : True ,
" allValue " : " .*(runner|forgejo).* " ,
" current " : { " selected " : True , " text " : [ " All " ] , " value " : [ " $__all " ] } ,
" options " : [ ] ,
" query " : { " query " : ' label_values( { job= " kube/pods " , namespace=~ " .*(runner|forgejo).* " }, '
' namespace) ' , " refId " : " LokiRunnerNamespace " } ,
}
2026-10-27 01:32:20 -04:00
# ---------------------------------------------------------------- runners -----
2026-10-27 01:36:02 -04:00
# 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.
2026-11-27 01:20:56 -05:00
RUN = ' namespace= " ci-runners " ,pod=~ " forgejo-runner-(amd64|arm64|deploy-arm64)-.* " '
2026-10-27 01:32:20 -04:00
SIRIUSSEC_FS = ' instance= " 10.10.0.2:9100 " ,mountpoint= " / " '
RPI_FS = ' instance= " 10.10.0.1:9100 " ,mountpoint= " / " '
runners = [
row ( " Runners & queue " , 0 ) ,
2026-11-27 01:20:56 -05:00
stat ( " Runner pods Ready " , [ target ( ' sum(kube_deployment_status_replicas_ready { namespace= " ci-runners " ,deployment=~ " forgejo-runner-.* " }) or vector(0) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 } ] ) ,
2026-10-27 01:36:02 -04:00
stat ( " Runner pods not Ready " , [ target ( ' sum(kube_pod_status_ready { %s ,condition= " false " } == 1) or vector(0) ' % RUN ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 " ) ,
2026-10-27 01:36:02 -04:00
stat ( " Last runner poll age " , [ target ( ' max(cnpg_actions_runners_last_online_seconds { namespace= " forgejo " }) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 } ] ) ,
2026-10-27 01:36:02 -04:00
stat ( " Queue depth " , [ target ( ' max(cnpg_actions_queue_depth { namespace= " forgejo " }) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 } ] ) ,
2026-10-27 01:36:02 -04:00
stat ( " Running now " , [ target ( ' max(cnpg_actions_running_total { namespace= " forgejo " }) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 5 , " w " : 4 , " x " : 16 , " y " : 1 } ,
desc = " Jobs currently executing. capacity=1 per runner, so >3 here means something is stuck. " ) ,
2026-10-27 01:36:02 -04:00
stat ( " Queue while running = contention " , [ target ( ' max((cnpg_actions_queue_depth { namespace= " forgejo " } > bool 0) * (cnpg_actions_running_total { namespace= " forgejo " } > bool 0)) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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) " ,
2026-10-27 01:36:02 -04:00
[ target ( ' cnpg_actions_jobs_window_total { namespace= " forgejo " ,window= " 24h " } ' , " status {{ status}} " ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 " ,
2026-10-27 01:36:02 -04:00
[ 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 " ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 " ,
2026-10-27 01:36:02 -04:00
[ target ( ' cnpg_actions_queue_oldest_pending_seconds { namespace= " forgejo " } ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 8 , " w " : 8 , " x " : 16 , " y " : 7 } , unit = " s " ,
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. " ) ,
2026-10-27 01:36:02 -04:00
ts ( " Memory working set per runner pod " , [ target ( ' sum by (pod) (container_memory_working_set_bytes { %s ,container!= " " }) ' % RUN , " {{ pod}} " ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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. " ) ,
row ( " Disk — the one that actually bites " , 24 ) ,
ts ( " Runner pod network I/O " , [ target ( ' sum by (pod) (rate(container_network_receive_bytes_total { %s }[5m])) ' % RUN , " {{ pod}} in " ) ,
target ( ' sum by (pod) (rate(container_network_transmit_bytes_total { %s }[5m])) ' % RUN , " {{ pod}} out " , ref = " B " ) ] ,
{ " h " : 8 , " w " : 8 , " x " : 0 , " y " : 25 } , unit = " Bps " , desc = " Image pulls and artifact traffic through the pod interface. " ) ,
2026-11-27 01:20:56 -05:00
stat ( " dind PVC nominal size " , [ target ( ' max(kube_persistentvolumeclaim_resource_requests_storage_bytes { namespace= " ci-runners " ,persistentvolumeclaim= " forgejo-runner-amd64 " }) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 8 , " w " : 4 , " x " : 8 , " y " : 25 } , unit = " bytes " ,
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. " ) ,
stat ( " siriussec root fs used " , [ target ( ' 100 * (1 - node_filesystem_avail_bytes { %s } / node_filesystem_size_bytes { %s }) ' % ( SIRIUSSEC_FS , SIRIUSSEC_FS ) ) ] ,
{ " h " : 8 , " w " : 4 , " x " : 12 , " y " : 25 } , unit = " percent " ,
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 % . " ,
thresholds = [ { " color " : " green " , " value " : None } , { " color " : " yellow " , " value " : 75 } , { " color " : " red " , " value " : 85 } ] ) ,
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. " ,
thresholds = [ { " color " : " red " , " value " : None } , { " color " : " yellow " , " value " : 30 } , { " color " : " green " , " value " : 90 } ] ) ,
ts ( " rpi root fs used % " , [ target ( ' 100 * (1 - node_filesystem_avail_bytes { %s } / node_filesystem_size_bytes { %s }) ' % ( RPI_FS , RPI_FS ) ) ] ,
{ " h " : 8 , " w " : 4 , " x " : 20 , " y " : 25 } , unit = " percent " ,
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. " ) ,
note ( " What this board can and cannot see " , """ \
* * Measured : * * runner Deployments ( kube - state - metrics ) , runner pods CPU / mem / net / restarts ( cAdvisor ) ,
runner liveness as * Forgejo * sees it ( ` action_runner . last_online ` ) , queue depth and job outcomes
( ` action_run_job ` via the CNPG exporter ) , and the host filesystems that CI fills ( node - exporter ) .
* * Not measurable — by design , not by omission : * *
- * * Per - job breakdown on the arm64 runner . * * ` forgejo - runner - arm64 ` and
` forgejo - runner - deploy - arm64 ` drive the * * host * * Docker socket ( gid 984 ) , so their jobs are
plain host containers with no pod identity . cAdvisor / kube - state - metrics see only the runner
pod itself . There is no per - job CPU / mem / disk on rpi and there cannot be one without changing
the runner to dind — which this board deliberately does not propose .
2026-10-27 02:05:57 -04:00
- * * Per - PV bytes for the dind PVC . * * kubelet 1.34 + no longer exports the alpha
` kubelet_volume_stats_ * ` set at all : its ` / metrics / volumes ` endpoint returns 404 on every node
here ( kubelet v1 .36 .4 ; upstream kubernetes / kubernetes #133847), so no scrape config can produce
those series and it is not a hostPath quirk . The usable proxy is the runner node ' s root
filesystem usage plus the PVC ' s requested size, both on this row — and the `RunnerDindDisk*`
alerts watch that same filesystem , scoped to nodes that run a runner .
2026-10-27 01:32:20 -04:00
""" , { " h " : 7, " w " : 24, " x " : 0, " y " : 33}),
]
# ----------------------------------------------------------------- cnpg -------
cnpg = [
row ( " Cluster health " , 0 ) ,
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. " ,
thresholds = [ { " color " : " green " , " value " : None } , { " color " : " yellow " , " value " : 70 } , { " color " : " red " , " value " : 90 } ] ) ,
stat ( " Manual switchover required " , [ target ( ' max by (namespace) (cnpg_collector_manual_switchover_required { %s }) ' % CLUSTER_NS ) ] ,
{ " h " : 5 , " w " : 4 , " x " : 16 , " y " : 1 } ,
desc = " 1 = the operator is asking for a manual switchover (e.g. after a fencing event). " ,
thresholds = [ { " color " : " green " , " value " : None } , { " color " : " red " , " value " : 1 } ] ) ,
docs(pitr): the plugin path is real — transcript, layout, metrics, 1.31 gate closed
Documents what the live migration actually produced (kanban t_5df331de):
- §8.3: restore manifest is externalClusters[].plugin + barmanObjectName/
serverName, with the 2026-11-19 rehearsal transcript (marker 23:04:53.07,
target 23:05:00Z, poison 23:05:15.80 -> marker present, poison gone).
- §8.4 (new): how the plugin is wired — vendored manifest, Service-annotation
registration, cert-manager dependency, ObjectStore/ScheduledBackup shape,
the injected init-sidecar, and the metrics family change.
- §8.1/§5.1: producer is the plugin; retention moved to the ObjectStore;
the "1.31 is a hard gate" caveat is replaced by "gate closed".
- §9/§10 + namespace table: cert-manager and barman-cloud are live state now,
with the verification log rows.
- pitr-restore.md rewritten for the plugin (manifest, sidecar log evidence,
the two-servers-name trap, retention location).
- CNPG dashboard: the `or` now prefers the plugin's metric — the legacy
cnpg_collector series still holds the PRE-migration timestamp.
2026-11-19 18:09:23 -05:00
stat ( " Last available backup " , [ target ( ' max by (namespace) (barman_cloud_cloudnative_pg_io_last_available_backup_timestamp { %s } or cnpg_collector_last_available_backup_timestamp { %s }) ' % ( CLUSTER_NS , CLUSTER_NS ) ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 5 , " w " : 4 , " x " : 20 , " y " : 1 } , unit = " dateTimeAsIso " ,
docs(pitr): the plugin path is real — transcript, layout, metrics, 1.31 gate closed
Documents what the live migration actually produced (kanban t_5df331de):
- §8.3: restore manifest is externalClusters[].plugin + barmanObjectName/
serverName, with the 2026-11-19 rehearsal transcript (marker 23:04:53.07,
target 23:05:00Z, poison 23:05:15.80 -> marker present, poison gone).
- §8.4 (new): how the plugin is wired — vendored manifest, Service-annotation
registration, cert-manager dependency, ObjectStore/ScheduledBackup shape,
the injected init-sidecar, and the metrics family change.
- §8.1/§5.1: producer is the plugin; retention moved to the ObjectStore;
the "1.31 is a hard gate" caveat is replaced by "gate closed".
- §9/§10 + namespace table: cert-manager and barman-cloud are live state now,
with the verification log rows.
- pitr-restore.md rewritten for the plugin (manifest, sidecar log evidence,
the two-servers-name trap, retention location).
- CNPG dashboard: the `or` now prefers the plugin's metric — the legacy
cnpg_collector series still holds the PRE-migration timestamp.
2026-11-19 18:09:23 -05:00
desc = " 0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, whose metric is `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`; the deprecated `cnpg_collector_*` name is the fallback for any cluster still on the in-tree path. Order matters: the legacy series is still scraped for portal and holds the PRE-migration timestamp, so it must not win the `or`. " ,
2026-10-27 01:32:20 -04:00
thresholds = [ { " color " : " red " , " value " : None } , { " color " : " green " , " value " : 1 } ] ) ,
row ( " Throughput " , 6 ) ,
ts ( " Transactions/s — commit vs rollback " ,
[ target ( ' sum by (namespace) (rate(cnpg_pg_stat_database_xact_commit { %s }[5m])) ' % CLUSTER_NS , " {{ namespace}} commit " ) ,
target ( ' sum by (namespace) (rate(cnpg_pg_stat_database_xact_rollback { %s }[5m])) ' % CLUSTER_NS , " {{ namespace}} rollback " , ref = " B " ) ] ,
{ " h " : 8 , " w " : 12 , " x " : 0 , " y " : 7 } , unit = " ops " ,
desc = " From pg_stat_database, which Forgejo ' s connection pool drives directly. " ) ,
ts ( " Commit share " , [ target ( ' sum(rate(cnpg_pg_stat_database_xact_commit { %s }[5m])) / clamp_min(sum(rate(cnpg_pg_stat_database_xact_commit { %s }[5m])) + sum(rate(cnpg_pg_stat_database_xact_rollback { %s }[5m])), 0.0000001) ' % ( CLUSTER_NS , CLUSTER_NS , CLUSTER_NS ) ) ] ,
{ " h " : 8 , " w " : 6 , " x " : 12 , " y " : 7 } , unit = " percentunit " ,
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 " ,
db(portal): migrate WAL archiving to the CNPG-I Barman Cloud plugin
CloudNativePG 1.30 deprecates spec.backup.barmanObjectStore and 1.31 removes
it, so the pin on 1.30.0 was a hard gate. This closes that gate:
- Vendors plugin-barman-cloud v0.16.0 verbatim into
infrastructure/databases/base/upstream/ (the operator manifest's pattern),
with a kustomize patch only for --log-level=info and resource bounds.
v0.16.0 requires CNPG >= 1.30 and is registered through Service
annotations; its operator<->plugin mTLS pair comes from cert-manager
(previous commit).
- Adds ObjectStore sirius-growth/portal-wal: the literal translation of the
retired barmanObjectStore block, with retentionPolicy 14d moved off the
Cluster (in the plugin, retention belongs to the store).
- Cluster portal drops spec.backup entirely and gains spec.plugins
(barman-cloud.cloudnative-pg.io, isWALArchiver, barmanObjectName
portal-wal, serverName portal). The server name is the barman prefix, so
the plugin keeps writing s3://pg-wal-archive/portal/{base,wals}/... — the
same objects the in-tree archiver left behind; the 14-day window stays
readable.
- ScheduledBackup portal-daily switches to method: plugin.
- databases waits on cert-manager; apps waits on databases (the ObjectStore
CRD ships with the plugin).
- CNPG dashboard: the backup timestamp metric family changes name under the
plugin, so the panel now accepts both.
2026-11-19 17:58:12 -05:00
desc = " Bytes of WAL written per second. sirius-growth/portal archives its WAL to the Linode Garage; forgejo/pg does not archive, so its WAL only ever fills the pg_wal directory. " ) ,
2026-10-27 01:32:20 -04:00
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 " ,
db(portal): migrate WAL archiving to the CNPG-I Barman Cloud plugin
CloudNativePG 1.30 deprecates spec.backup.barmanObjectStore and 1.31 removes
it, so the pin on 1.30.0 was a hard gate. This closes that gate:
- Vendors plugin-barman-cloud v0.16.0 verbatim into
infrastructure/databases/base/upstream/ (the operator manifest's pattern),
with a kustomize patch only for --log-level=info and resource bounds.
v0.16.0 requires CNPG >= 1.30 and is registered through Service
annotations; its operator<->plugin mTLS pair comes from cert-manager
(previous commit).
- Adds ObjectStore sirius-growth/portal-wal: the literal translation of the
retired barmanObjectStore block, with retentionPolicy 14d moved off the
Cluster (in the plugin, retention belongs to the store).
- Cluster portal drops spec.backup entirely and gains spec.plugins
(barman-cloud.cloudnative-pg.io, isWALArchiver, barmanObjectName
portal-wal, serverName portal). The server name is the barman prefix, so
the plugin keeps writing s3://pg-wal-archive/portal/{base,wals}/... — the
same objects the in-tree archiver left behind; the 14-day window stays
readable.
- ScheduledBackup portal-daily switches to method: plugin.
- databases waits on cert-manager; apps waits on databases (the ObjectStore
CRD ships with the plugin).
- CNPG dashboard: the backup timestamp metric family changes name under the
plugin, so the panel now accepts both.
2026-11-19 17:58:12 -05:00
desc = " pg_stat_archiver.failed_count. Archiving is configured only on sirius-growth/portal (Barman Cloud plugin -> Linode Garage); forgejo/pg has no archiver, so any non-zero value is the honest signal that WAL failed to reach the archive. " ) ,
2026-10-27 01:32:20 -04:00
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. " ) ,
note ( " Known unknowns on the CNPG board " , """ \
db(portal): migrate WAL archiving to the CNPG-I Barman Cloud plugin
CloudNativePG 1.30 deprecates spec.backup.barmanObjectStore and 1.31 removes
it, so the pin on 1.30.0 was a hard gate. This closes that gate:
- Vendors plugin-barman-cloud v0.16.0 verbatim into
infrastructure/databases/base/upstream/ (the operator manifest's pattern),
with a kustomize patch only for --log-level=info and resource bounds.
v0.16.0 requires CNPG >= 1.30 and is registered through Service
annotations; its operator<->plugin mTLS pair comes from cert-manager
(previous commit).
- Adds ObjectStore sirius-growth/portal-wal: the literal translation of the
retired barmanObjectStore block, with retentionPolicy 14d moved off the
Cluster (in the plugin, retention belongs to the store).
- Cluster portal drops spec.backup entirely and gains spec.plugins
(barman-cloud.cloudnative-pg.io, isWALArchiver, barmanObjectName
portal-wal, serverName portal). The server name is the barman prefix, so
the plugin keeps writing s3://pg-wal-archive/portal/{base,wals}/... — the
same objects the in-tree archiver left behind; the 14-day window stays
readable.
- ScheduledBackup portal-daily switches to method: plugin.
- databases waits on cert-manager; apps waits on databases (the ObjectStore
CRD ships with the plugin).
- CNPG dashboard: the backup timestamp metric family changes name under the
plugin, so the panel now accepts both.
2026-11-19 17:58:12 -05:00
- * * Backups exist on one cluster only . * * ` sirius - growth / portal ` archives WAL + daily base backups
through the CNPG - I Barman Cloud plugin ( ` ObjectStore portal - wal ` ) into the Linode Garage ;
` forgejo / pg ` has no archiver by design . The " Last available backup " stat reads 0 only if neither
the plugin ' s `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` nor the legacy
` cnpg_collector_last_available_backup_timestamp ` series exists .
2026-10-27 01:32:20 -04:00
- * * Single instance . * * Both clusters run ` instances : 1 ` , so replication lag / streaming replicas /
in recovery are structurally zero . The panels show the zero and say so instead of hiding them .
- * * Query age vs transaction age . * * CNPG ' s default query set exposes
` cnpg_backends_max_tx_duration_seconds ` ( transaction age ) . Per - statement ` query_start ` age is not in
the default set ; adding it would need another custom query in the cluster ' s
` customQueriesConfigMap ` .
- * * Permissions . * * Custom queries run as ` cnpg_metrics_exporter ` , not superuser . See
docs / monitoring - dashboards . md for the GRANT the Forgejo Actions metrics need .
""" , { " h " : 8, " w " : 24, " x " : 0, " y " : 40}),
]
# -------------------------------------------------------------- workloads -----
workloads = [
row ( " Cluster " , 0 ) ,
2026-10-27 01:40:15 -04:00
stat ( " Nodes Ready " , [ target ( ' count(kube_node_status_condition { condition= " Ready " ,status= " true " } == 1) or vector(0) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 5 , " w " : 4 , " x " : 0 , " y " : 1 } , thresholds = [ { " color " : " red " , " value " : None } , { " color " : " yellow " , " value " : 2 } , { " color " : " green " , " value " : 3 } ] ) ,
2026-10-27 01:36:02 -04:00
stat ( " Nodes with DiskPressure " , [ target ( ' sum(kube_node_status_condition { condition= " DiskPressure " ,status= " true " } == 1) or vector(0) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " 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 } ] ) ,
2026-10-27 01:40:15 -04:00
stat ( " Pending pods " , [ target ( ' sum(kube_pod_status_phase { phase= " Pending " } == 1) or vector(0) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 5 , " w " : 4 , " x " : 8 , " y " : 1 } ,
desc = " Pods that cannot be scheduled — usually an unschedulable taint or an exhausted resource request. " ,
thresholds = [ { " color " : " green " , " value " : None } , { " color " : " red " , " value " : 1 } ] ) ,
stat ( " Internal gateway probes OK " , [ target ( ' sum(probe_success { job= " internal-gateway " }) ' ) ] ,
{ " h " : 5 , " w " : 4 , " x " : 12 , " y " : 1 } ,
desc = " blackbox-exporter probes of http://10.10.0.2:8081/ and :8084/ (monitoring/controllers/home/gateway-probe.yaml). 2 = both internal services answering. " ,
thresholds = [ { " color " : " red " , " value " : None } , { " color " : " yellow " , " value " : 1 } , { " color " : " green " , " value " : 2 } ] ) ,
2026-10-27 01:40:15 -04:00
stat ( " PVCs bound " , [ target ( ' sum(kube_persistentvolumeclaim_status_phase { phase= " Bound " } == 1) or vector(0) ' ) ] ,
2026-10-27 01:32:20 -04:00
{ " h " : 5 , " w " : 4 , " x " : 16 , " y " : 1 } ) ,
stat ( " PVC capacity requested " , [ target ( ' sum(kube_persistentvolumeclaim_resource_requests_storage_bytes) ' ) ] ,
{ " h " : 5 , " w " : 4 , " x " : 20 , " y " : 1 } , unit = " bytes " ,
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. " ) ,
ts ( " Internal gateway probe result " , [ target ( ' probe_success { job= " internal-gateway " } ' , " {{ instance}} " ) ] ,
{ " h " : 8 , " w " : 12 , " x " : 12 , " y " : 32 } , unit = " short " ,
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}} " ) ] ,
{ " h " : 8 , " w " : 8 , " x " : 0 , " y " : 41 } , unit = " percent " ) ,
ts ( " Node memory used " , [ target ( ' 100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) ' , " {{ instance}} " ) ] ,
{ " h " : 8 , " w " : 8 , " x " : 8 , " y " : 41 } , unit = " percent " ) ,
ts ( " Filesystem used % " ,
[ target ( ' 100 * (1 - node_filesystem_avail_bytes { mountpoint= " / " ,fstype!~ " tmpfs|overlay " } / node_filesystem_size_bytes { mountpoint= " / " ,fstype!~ " tmpfs|overlay " }) ' , " {{ instance}} / " ) ] ,
{ " h " : 8 , " w " : 8 , " x " : 16 , " y " : 41 } , unit = " percent " ,
desc = " Root filesystem per node — the local-path PVs, the dind data-root and the Pi ' s host-docker job containers all land on these. " ) ,
note ( " Known unknowns on this board " , """ \
2026-10-27 02:05:57 -04:00
- * * PVC usage is not charted , only requested capacity . * * kubelet 1.34 + dropped the alpha
` kubelet_volume_stats_ * ` metrics ( its ` / metrics / volumes ` endpoint 404 s on every node here ) , so
there is nothing to chart per PV . Node filesystem usage is the honest proxy for " how full is
the disk these PVs live on " .
2026-10-27 01:32:20 -04:00
- * * Namespaces are not filtered . * * With this few workloads an unfiltered board is more useful than a
variable that hides the one namespace you needed to see .
- * * No Alertmanager . * * Alerts from ` PrometheusRule ` objects are visible in Prometheus / alerts and in
Grafana → Alerting , but nothing pages .
""" , { " h " : 8, " w " : 24, " x " : 0, " y " : 49}),
]
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
# ----------------------------------------------------------------- logs ------
# Time-to-answer panels for an incident: who touched a Secret (apiserver audit)
# and what a pod said before it died. Both run against the Loki datasource
# (infrastructure/logging/datasource.yaml, uid `loki`).
logs_panels = [
row ( " kube-apiserver audit — secret access " , 0 ) ,
stat ( " Secret events (1h) " ,
[ loki_target ( " sum(count_over_time( " + AUDIT_SECRETS + " [1h])) " , instant = True ) ] ,
{ " h " : 5 , " w " : 4 , " x " : 0 , " y " : 1 } , ds = DS_LOKI ,
desc = " Count of audit records whose object is a Secret, filtered on the stream labels "
" the Alloy audit pipeline emits. No log-line parsing involved. " ) ,
ts ( " Secret access by user " ,
[ loki_target ( " sum by (user) (count_over_time( " + AUDIT_SECRETS + " | json [5m])) " ,
legend = " {{ user}} " ) ] ,
{ " h " : 8 , " w " : 20 , " x " : 4 , " y " : 1 } , ds = DS_LOKI , fill = 10 , stack = True ,
desc = " The ' who read that credential ' view. `user` comes from user.username in the audit "
" record, so `| json` is needed for the grouping; the resource filter stays in the "
" selector as a label matcher. " ) ,
logs ( " Secret access log — verb, object, caller " ,
[ loki_target ( AUDIT_SECRETS + ' | json | line_format " {{ .verb}} '
' {{ .subresource}} {{ .ns}}/ {{ .name}} — {{ .user}} ( {{ .code}}) " ' ) ] ,
{ " h " : 10 , " w " : 24 , " x " : 0 , " y " : 9 } ,
desc = " One line per audit record that touched a Secret. Secret bodies are never stored: "
" the pipeline allowlists fields and drops requestObject/responseObject. " ) ,
row ( " Pod logs " , 19 ) ,
logs ( " Errors — namespace = $namespace " ,
[ loki_target ( " { " + POD_SEL + ' , namespace=~ " $namespace " } |= " error " ' ) ] ,
{ " h " : 9 , " w " : 12 , " x " : 0 , " y " : 20 } ,
desc = " The ordinary ' what did the pod say before it died ' query. Substring filter, so it "
" catches `error` anywhere in the line. " ) ,
logs ( " Error / exception / fatal / panic (case-insensitive) " ,
[ loki_target ( " { " + POD_SEL + ' , namespace=~ " $namespace " } '
' |~ " (?i)error|exception|fatal|panic " ' ) ] ,
{ " h " : 9 , " w " : 12 , " x " : 12 , " y " : 20 } ,
desc = " Wider net for stacks that log `Exception`, `FATAL` or `panic:` instead of the word "
" `error`. " ) ,
row ( " CI runners (forgejo / forgejo-runners) " , 29 ) ,
logs ( " Runner pod logs " ,
[ loki_target ( " { " + POD_SEL + " , " + RUNNER_NS + " } " ) ] ,
{ " h " : 9 , " w " : 12 , " x " : 0 , " y " : 30 } ,
desc = " Everything the runner pods print — job container output, dind, and the runner ' s own "
" poll/registration lines. The namespace comes from the `runner_ns` variable, which "
" matches any *runner* namespace (forgejo, forgejo-runners, ci-runners) so the panel "
" survives the t_2bbe34a8 move without an edit. " ) ,
ts ( " Runner error / fail lines per 5m " ,
[ loki_target ( " sum by (namespace) (count_over_time( { " + POD_SEL + " , " + RUNNER_NS +
' } |~ " (?i)error|fail " [5m])) ' , legend = " {{ namespace}} " ) ] ,
{ " h " : 9 , " w " : 12 , " x " : 12 , " y " : 30 } , ds = DS_LOKI , fill = 10 , stack = True ,
desc = " Coarse CI pain signal. A silent stall (a build looping on `Ign:` with no error) does "
" not show here — check the log panel above for that. " ) ,
row ( " How to read these streams " , 39 ) ,
note ( " Field names and retention " , " \n " . join ( [
" Loki is single-binary in the `logging` namespace: **192 h (8 d)** retention on an 8Gi PVC, " ,
" fed by the Alloy DaemonSet. These panels only read it. " ,
" " ,
" | `job` | source | stream labels | " ,
" |---|---|---| " ,
" | `kube/pods` | every container ' s stdout (`/var/log/pods`) | `namespace, pod, container, node` | " ,
" | `kube/apiserver-audit` | `siriussec` ' s `/var/log/kubernetes/audit/audit.log` | `resource, verb` | " ,
" | `systemd-journal` | node journals | `unit, host, level` | " ,
" | `docker/json` | the Pi ' s docker container logs | `container` | " ,
" " ,
" **The audit field names are the Alloy pipeline ' s allowlist, not the raw audit event ' s.** " ,
" `objectRef.resource` arrives as the stream label `resource` and `user.username` as the " ,
" line field `user`, so the usable query is " ,
" ` { job= \" kube/apiserver-audit \" , resource= \" secrets \" } | json` — an `objectRef_resource` or " ,
" `user_username` matcher returns **zero rows**. Secret bodies are never shipped: the " ,
" pipeline packs an allowlist and drops `requestObject`/`responseObject` " ,
" (`docs/logging.md`, `infrastructure/logging/alloy/config.alloy`). " ,
] ) , { " h " : 8 , " w " : 24 , " x " : 0 , " y " : 40 } , h = 8 ) ,
]
2026-10-27 01:32:20 -04:00
DOCS = {
" forgejo-runners " : ( " Forgejo Runners " ,
[ " homelab " , " forgejo " , " runners " ] ,
" Runners, CI queue depth and job outcomes, plus the disk that CI actually fills. " ,
" Runner health as the cluster sees it (kube-state-metrics/cAdvisor) and as Forgejo "
" sees it (action_runner.last_online, action_run_job), plus the filesystem that the "
" dind data-root and the Pi ' s host-docker jobs consume. " ) ,
" cnpg-postgres " : ( " CNPG Postgres " ,
[ " homelab " , " postgres " , " cnpg " ] ,
" Both CloudNativePG clusters: connections, throughput, errors, size, WAL, replication. " ,
" Metrics come from CNPG ' s instance-manager exporter on :9187, scraped by the "
" per-cluster PodMonitors in apps/base/*/podmonitor.yaml. " ) ,
" home-lab-workloads " : ( " Home lab workloads " ,
[ " homelab " , " overview " ] ,
" Per-namespace requests vs usage, top pods, node health and internal-service availability. " ,
" Cluster-wide view: who is using CPU/memory, what is Pending or restarting, how full "
" the nodes ' disks are, and whether the WireGuard-only internal services answer. " ) ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
" logs " : ( " Logs " ,
[ " homelab " , " logs " , " loki " , " audit " ] ,
" Loki queries worth having: who read a Secret (apiserver audit), pod errors by namespace, CI runner output. " ,
" Loki single-binary in the `logging` namespace (192 h retention) holds pod logs, node journals, "
" the Pi ' s docker logs and the kube-apiserver audit stream. The audit panels answer ' who read "
" that credential ' ; the pod panels answer ' what did the pod say before it died ' . Field names "
" are the Alloy pipeline ' s allowlist, not the raw audit event ' s — see the note panel. " ) ,
2026-10-27 01:32:20 -04:00
}
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
PANELS = { " forgejo-runners " : runners , " cnpg-postgres " : cnpg , " home-lab-workloads " : workloads ,
" logs " : logs_panels }
2026-10-27 01:32:20 -04:00
os . makedirs ( OUT_DIR , exist_ok = True )
for uid , panels in PANELS . items ( ) :
_next_id [ 0 ] = 0
title , tags , desc , long_desc = DOCS [ uid ]
d = dashboard ( uid , title , tags , panels , long_desc ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
variables = ( [ ns_variable ( ) ] if uid == " cnpg-postgres "
else [ loki_ns_variable ( ) , loki_runner_ns_variable ( ) ]
if uid == " logs " else None ) )
2026-10-27 01:32:20 -04:00
doc = {
" apiVersion " : " v1 " ,
" kind " : " ConfigMap " ,
" metadata " : {
" name " : " grafana-dashboard- " + uid ,
" namespace " : " monitoring " ,
" labels " : { " grafana_dashboard " : " 1 " , " app.kubernetes.io/part-of " : " homelab-dashboards " } ,
monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload runbook
The log store shipped in t_34ddaa83 but nothing could read it: the Loki datasource
ConfigMap was live and written into Grafana's provisioning volume, and Grafana still
listed only Prometheus + Alertmanager. Root cause was not the ConfigMap. The
datasource sidecar writes the file and then POSTs
/api/admin/provisioning/datasources/reload with monitoring/grafana-admin, which was
401-ing because Grafana's DB password had drifted from that Secret (the documented
"the Secret is only the seed" behaviour) — Grafana reads provisioning/datasources
only at startup, so the datasource never loaded.
- Reset the live admin password to the Secret's value (in-pod `grafana cli
admin reset-admin-password`, value read from the Secret and never printed), so
seed and DB match again and the sidecar's reload returns 200. Documented in
docs/grafana-persistence.md, including the sidecar consequence of drift.
- New generated dashboard `logs` (uid: logs) with the two queries worth having:
secret access over time by user from the apiserver audit stream, and pod errors
by namespace, plus the runner namespaces and a note panel on field names.
- The audit stream's names are the Alloy allowlist's, not the audit event's:
objectRef.resource arrives as the stream label `resource` and user.username as
the field `user`. `| json | objectRef_resource="secrets"` returns 0 rows
(measured); the panels use `resource="secrets"` in the selector + `| json` for
the user dimension. No pipeline, retention or filter change.
- Runner panels discover their namespace via a `runner_ns` variable
(.*(runner|forgejo).*) instead of pinning one name, so the t_2bbe34a8 move to
ci-runners needs no edit here.
- validate_panels.py now dispatches on the target's datasource and queries Loki
for `loki` panels (a logs panel must return rows, not just series).
2026-11-27 01:23:03 -05:00
# No grafana_folder annotation: the sidecar's API-backed import would need
# the admin credential, so the dashboards are imported by Grafana's *file*
# provider, which ignores per-dashboard folder annotations and puts every
# board in General next to the chart's own 28. Verified in grafana.db.
# (Since 2026-11-27 the live admin password equals monitoring/grafana-admin
# again — the DB was reset to the Secret's value — but the sidecar still
# imports by file, so nothing here depends on that.)
2026-10-27 01:40:15 -04:00
" annotations " : { " homelab.siriusdevops.com/managed-by " : " monitoring/controllers/home/dashboards/build.py " } ,
2026-10-27 01:32:20 -04:00
} ,
" data " : { uid + " .json " : json . dumps ( d , indent = 2 ) + " \n " } ,
}
path = os . path . join ( OUT_DIR , uid + " .yaml " )
with open ( path , " w " ) as f :
f . write ( " # GENERATED by monitoring/controllers/home/dashboards/build.py — edit the script, not this file. \n " )
f . write ( " # Provisioned by the kube-prometheus-stack dashboard sidecar (label grafana_dashboard=1, \n " )
f . write ( " # NAMESPACE=ALL), so it wins over any UI edit. Dashboard uid: %s \n " % uid )
# hand-rolled YAML emitter: keeps the JSON block literal and diffable
f . write ( " apiVersion: v1 \n kind: ConfigMap \n metadata: \n name: %s \n namespace: monitoring \n " % doc [ " metadata " ] [ " name " ] )
f . write ( " labels: \n grafana_dashboard: \" 1 \" \n app.kubernetes.io/part-of: homelab-dashboards \n " )
2026-10-27 01:40:15 -04:00
f . write ( " annotations: \n homelab.siriusdevops.com/managed-by: monitoring/controllers/home/dashboards/build.py \n " )
2026-10-27 01:32:20 -04:00
f . write ( " data: \n %s .json: | \n " % uid )
for line in doc [ " data " ] [ uid + " .json " ] . rstrip ( " \n " ) . split ( " \n " ) :
f . write ( " " + line + " \n " )
print ( " wrote " , path )