monitoring(logs): a readable Loki — Logs dashboard + provisioning-reload fix #74
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_050d5bb8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Loki has 8 days of retained logs and no reader. The gap was not the ConfigMap —
monitoring/loki-datasourcewas already live and the file was sitting in Grafana'sprovisioning volume; Grafana's
/api/datasourcesstill listed only Prometheus +Alertmanager.
Root cause
The datasource sidecar writes the file, then POSTs
/api/admin/provisioning/datasources/reloadwithmonitoring/grafana-admin. That POSTwas returning 401 because Grafana's DB password had drifted from the Secret (the
documented "the Secret is only the first-boot seed, the DB owns the password"
behaviour). Grafana reads
provisioning/datasourcesonly at startup, so the file ondisk was never loaded — for 40 minutes, with no error anywhere.
Fixed by resetting the DB password to the Secret's value in-pod
(
grafana cli admin reset-admin-password, value read from the Secret, never printed),so seed and DB match again. The reload then answers 200 and the datasource appears.
Post-fix the datasource was loaded by a reload, no Grafana pod restart was needed.
What this PR adds
logsdashboard (uidlogs, generated bybuild.py→logs.yaml):{job="kube/apiserver-audit", resource="secrets"} | jsongrouped
by (user), plus a stat and a readable "verb / object / caller" log panel.{job="kube/pods", namespace=~"$namespace"} |= "error",and a wider
|~ "(?i)error|exception|fatal|panic"panel.runner_nsvariable matching.*(runner|forgejo).*,so the t_2bbe34a8 move to
ci-runnersneeds no edit here.validate_panels.pydispatches on the target's datasource and queries Loki forlokipanels (a logs panel must return rows, not just series).docs/logging.md(how to query, the reload requirement, the field-nametrap),
docs/monitoring-dashboards.md(four boards),docs/grafana-persistence.md(drift breaks the sidecars, not just the login).
The card's query, as written, cannot work
{job="kube/apiserver-audit"} | json | objectRef_resource="secrets"returns 0 rows(measured through Grafana's proxy). Alloy re-emits each audit record as a flat
allowlist, so
objectRef.resourcearrives as the stream labelresourceanduser.usernameas the fielduser. The dashboard uses the equivalent that works:{job="kube/apiserver-audit", resource="secrets"} | json.No change to Alloy's sources, the audit filter, Loki retention, or any RBAC.
Verification (live)
/api/datasources/uid/loki→type: loki,url: http://loki.logging.svc.cluster.local:3100/api/datasources/uid/loki/health→{"status":"OK"}{job="kube/pods"}&limit=5→ 5 rowsuservaluesvalidate_panels.py→ all 7 Loki panel targets OK (rows, not just series)