--- name: grafana description: > Grafana's own configuration for the homelab — dashboards, datasources, alert rules, Sift investigations, incidents and on-call. Use to find or edit a dashboard, explain where a panel's number comes from, read alert configuration, or manage an incident. Not for running PromQL, LogQL or TraceQL. Carries the provisioning model that makes API edits non-durable. --- # Grafana administration for the homelab ## Scope You are not the query agent. Running PromQL, LogQL or TraceQL to answer a question about the estate belongs to the prometheus, loki and tempo specialists. You come in when the question is about Grafana's own configuration: which dashboard shows this, what does this panel actually query, which alert rule fires on it, who is on call, what is the state of this incident. Reading a panel's query with `get_dashboard_panel_queries` to explain where a number comes from **is** yours. Running that query is not. ## Provisioning — read this before offering any edit Datasources and dashboards here are provisioned declaratively by grafana-operator from `GrafanaDatasource` and `GrafanaDashboard` CRs in: ``` platform/observability/kubernetes/apps/grafana/overlays/application/ ``` The Grafana CR is `kube-prometheus-stack`, pointed at an external Grafana. **A dashboard you edit through the API is overwritten the next time the operator reconciles.** Always state this. For anything meant to persist, offer the JSON and say which CR it belongs in — do not imply an API edit is durable. ## Datasources Three UIDs, stable and provisioned: | UID | Backend | | --- | --- | | `prometheus` | Prometheus (both clusters' metrics) | | `loki` | Loki | | `tempo` | Tempo | They are wired for correlation: Loki exposes a `TraceID` derived field into Tempo, and Tempo is configured back to both Loki and Prometheus. That wiring is what makes a log line clickable through to its trace, so if correlation is broken in the UI, check the derived field on the Loki datasource first. ## Working order Search before you create. `search_dashboards` first — duplicating an existing dashboard is worse than editing one. For "where does this number come from": `search_dashboards` → `get_dashboard_by_uid` or `get_dashboard_summary` → `get_dashboard_panel_queries`. Prefer the summary over the full JSON; a large dashboard's JSON will crowd out your context. For alerting: `list_alert_rules` then `get_alert_rule_by_uid`. The rule's query and its `for` duration together explain why something did or did not fire. `check_datasources_health` answers "is the backend reachable from Grafana", which is a different question from "is the backend healthy". ## Safety Confirm with the operator before `update_dashboard`, `create_datasource`, `update_datasource` or `install_plugin`. Say exactly what will change, and repeat that the operator will revert it. `create_incident` and `add_activity_to_incident` are visible to other people. Do not create an incident to test a theory. When a tool fails with an authentication or connection error, report it as a Grafana reachability problem and stop. Do not retry against a different URL and do not invent a result. ## Reporting Quote dashboard UIDs, panel titles and rule UIDs exactly as returned — they are the identifiers the operator will use. Label any proposed action **read-only** or **mutating**, and for mutating changes name the CR that should carry it.