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:
parent
2ae67faf98
commit
6b91152a79
7 changed files with 828 additions and 35 deletions
|
|
@ -186,13 +186,47 @@ the audit history was then re-ingested through the fixed pipeline.
|
|||
## Querying
|
||||
|
||||
Grafana datasource `Loki` (`uid: loki`, `infrastructure/logging/datasource.yaml`,
|
||||
loaded by the kube-prometheus-stack datasource sidecar) → Explore → Loki.
|
||||
loaded by the kube-prometheus-stack datasource sidecar) → Explore → Loki. The
|
||||
saved queries live on the **Logs** dashboard (`uid: logs`,
|
||||
`monitoring/controllers/home/dashboards/logs.yaml`, generated by `build.py`):
|
||||
|
||||
```
|
||||
http://10.10.0.2:8081/d/logs/
|
||||
```
|
||||
|
||||
From inside the cluster: `http://loki.logging.svc.cluster.local:3100`.
|
||||
From the Legion over WireGuard: `kubectl -n logging port-forward svc/loki 3100:3100`.
|
||||
No Gateway/listener is published for this — the store is not exposed outside the
|
||||
mesh and has no auth layer of its own.
|
||||
|
||||
**A new or edited datasource ConfigMap needs a provisioning reload.** Grafana
|
||||
reads `provisioning/datasources` only at startup; the sidecar writes the file but
|
||||
the thing that makes Grafana read it is the sidecar's own
|
||||
`POST /api/admin/provisioning/datasources/reload`, authenticated with
|
||||
`monitoring/grafana-admin`. If the DB password has drifted from that Secret the
|
||||
POST 401s, the file is on disk and the datasource never appears — which looks
|
||||
like a broken ConfigMap. Reload by hand with the Secret's credential:
|
||||
|
||||
```bash
|
||||
kubectl -n monitoring port-forward svc/kube-prometheus-stack-grafana 3000:80 &
|
||||
curl -u "admin:$GF_ADMIN_PASSWORD" -X POST \
|
||||
http://127.0.0.1:3000/api/admin/provisioning/datasources/reload # 200
|
||||
```
|
||||
|
||||
**The audit stream's field names are not the audit event's.** Alloy re-emits each
|
||||
record as a flat allowlist (`infrastructure/logging/alloy/config.alloy`), so
|
||||
`objectRef.resource` arrives as the **stream label** `resource` and
|
||||
`user.username` as the line field `user`:
|
||||
|
||||
```logql
|
||||
{job="kube/apiserver-audit", resource="secrets"} | json # who touched a Secret
|
||||
```
|
||||
|
||||
`{job="kube/apiserver-audit"} | json | objectRef_resource="secrets"` returns
|
||||
**zero rows** — measured 2026-11-27. `resource`/`verb` are stream labels, so put
|
||||
them in the selector (Loki prunes streams before parsing); `user`, `ns`, `name`,
|
||||
`code`, `sourceIP` are JSON fields and need `| json`.
|
||||
|
||||
Useful LogQL:
|
||||
|
||||
```logql
|
||||
|
|
@ -200,6 +234,7 @@ Useful LogQL:
|
|||
{namespace="kube-system", container="cilium-agent"} |= "error"
|
||||
{job="systemd-journal", node="siriussec"} |= "sshd" # node-level auth activity
|
||||
sum by (namespace) (count_over_time({job="kube/pods"}[1h]))
|
||||
sum by (user) (count_over_time({job="kube/apiserver-audit", resource="secrets"} | json [5m]))
|
||||
```
|
||||
|
||||
Label cardinality is bounded: `namespace, pod, container, node, stream, job`
|
||||
|
|
|
|||
Loading…
Reference in a new issue