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).
This commit is contained in:
Lance Walters 2026-11-27 01:23:03 -05:00
commit 6b91152a79
7 changed files with 828 additions and 35 deletions

View file

@ -53,6 +53,16 @@ So: changing `grafana-admin` alone on a populated PVC does **nothing**. That is
by design (no silent password resets on redeploy), and it is exactly why the
recovery path below matters.
> **Drift breaks the sidecars, not just the login.** The pod's sidecars (`grafana-sc-dashboard`,
> `grafana-sc-datasources`) carry `REQ_USERNAME`/`REQ_PASSWORD` from `grafana-admin` and POST
> `/api/admin/provisioning/{dashboards,datasources}/reload` as their "make Grafana read what I just
> wrote" step. Once the DB password has drifted from the Secret that POST returns **401**, so a
> datasource ConfigMap is written into `/etc/grafana/provisioning/datasources` and never loaded:
> the datasource is simply absent from `/api/datasources` while the file sits in the pod. Observable
> 2026-11-27 with the Loki datasource (ConfigMap live, file in the volume, no datasource in Grafana
> for 40 minutes). The DB was then reset to the Secret's value, so the seed and the DB match again
> and the reload answers **200**. Fix drift the same way before debugging a "missing" datasource.
## Recovery: reset a lost admin password
The trap with a persistent DB is that re-applying the Secret no longer helps.