Repository navigation
Description
Update 2026-11-26 (infra move): the environment dashboards moved to dan-petty/homelab, and sre-service.json is now the generated devops-sre-service.json there.
This issue keeps the SRE template, k8s/devops/dashboards/devops-cli.json and docs/DESIGN.md. The rebuild of the service dashboards is in the homelab follow-up.
Follow-up: dan-petty/homelab#296.
Problem or Motivation
DESIGN.md C8 (docs/DESIGN.md:226) asks for deploys and incidents as vertical 1 px dotted lines in color.fg-muted with a label above the plot. No dashboard shows these lines. On 2026-11-12, 0 of the 16 dashboards in k8s/monitoring/dashboards/ had an annotation query other than the built-in query, and Grafana stored 0 annotations (/api/annotations?from=0).
Prometheus has the data now:
sum by (name, phase) (increase(argocd_app_sync_total[24h]))gave 49Succeededsyncs and 0Failedsyncs in 24 h. The labelnameholds the Application (devops 25, monitoring 7, prometheus 4, llm 3, grafana 2). Argo CD sends this metric through its ServiceMonitor (k8s/argocd/values.yaml:103-106).count by (severity) (max_over_time(ALERTS{alertstate="firing"}[7d]))gave 2 critical series and 35 warning series in 7 d.
With these lines, a reader of the readable dashboards (#4675) and the weekly review (#4679) can connect a change in a signal to a deploy or to an alert. The change needs no credential, no new service and no glue code.
Proposed Solution & Architectural Design
Add two Prometheus annotation queries to k8s/devops/dashboards/devops-cli.json and to the SRE template that builds the service dashboards only. Do not change the dashboards copied from upstream: they stay as they are published (docs/DESIGN.md:259).
-
Deploys, with step
60sand titleFormat{{name}} sync:sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0 -
Incidents, with titleFormat
{{alertname}}:ALERTS{alertstate="firing", severity="critical"} -
In the same pull request, record a known gap in the Grafana row of
docs/DESIGN.md(line 259): Grafana shows the annotation text only on hover. Thus the lines do not meet the C8 label above the plot, or C11 ("No information is only in a hover").
#5184 then puts the same two queries into each service dashboard that it builds.
Cost: one or two more queries at each dashboard load. A self-heal sync also counts as a sync. No data leaves the cluster.
Target Subsystem
Kubernetes & Minikube Automation (k8s/monitoring/dashboards/, docs/DESIGN.md).
Existing Tool Considered
Grafana dashboard annotation queries on the Prometheus data source (core Grafana OSS 13.3.1, deployed), with the metrics argocd_app_sync_total (Argo CD) and ALERTS (Prometheus). No new code.
Rejected: the Argo CD Notifications Grafana service. It keeps the annotations after the 30 d Prometheus retention. But it needs a Grafana service account with the Editor role, a new Kubernetes object of kind Secret for its key, and two NetworkPolicy changes (monitoring ingress, argocd egress). The Prometheus query gives the same lines with none of these.
Acceptance Criteria
-
jq '[.annotations.list[] | select(.builtIn != 1) | .expr]'ondevops-cli.jsonand onsre-service.jsongives the deploy query and the incident query. -
git diff --stat origin/mainshows no change to a dashboard copied from upstream. - The deploy query through the Grafana MCP
query_prometheusover the last 24 h returns one or more series. - The incident query over the last 7 d returns one series for each critical alert that fired (2 in the 7 d before 2026-11-12).
-
uv run devops grafana dashboards lint k8s/devops/dashboards/reports no new defect. - The Grafana MCP
get_panel_imageof one time-series panel ofdevops-cli.jsonover 24 h shows a vertical line at a sync time. - The Grafana row of
docs/DESIGN.mdstates the hover-only gap against C8 and C11.
Related
#4675 (readable dashboards), #4679 (weekly review), #5184 (SRE template), dan-petty/homelab#351 (the upstream Argo CD dashboards stay as published and get no annotations).
Owner approved on 2026-11-12.
Source: #4675
Alternatives check of 2026-12-01: in-use.
The repository already uses this tool.
Tool: grafana/grafana (https://github.com/grafana/grafana), AGPL-3.0, last activity 2026-12-01, maintained.
Reason: Grafana OSS is already deployed and the issue names its Prometheus annotation queries as the solution. Two queries draw the deploy and alert lines with no new service, credential or NetworkPolicy. Only the label above the plot stays unmet.
Covers:
- Prometheus annotation query draws a vertical line at each deploy or alert time
- Annotation query holds step, titleFormat and a data source
- No new service, credential or NetworkPolicy change needed
Lacks:
- Annotation text shows only on hover, so no label above the plot
- Lines vanish with the 30 day Prometheus retention
- Only Succeeded syncs are queried, so failed syncs draw no line
- A self-heal sync also draws a line
Proposed design
Problem statement
The own Grafana dashboards show no deploy or incident annotation lines, so a reader cannot connect a change in a signal to a deploy or to an alert. The issue's devops-cli.json is k8s/devops/dashboards/devops-cli.json (uid devops-cli-telemetry), and its sre-service.json is the generated k8s/monitoring/dashboards/devops-sre-service.json. Add two Prometheus annotation queries, one for successful Argo CD syncs and one for firing critical alerts, to the CLI dashboard and, through the SRE template, to each service dashboard, and record the hover-only gap of Grafana annotations in the Grafana row of docs/DESIGN.md.
Acceptance criteria
Requirement: Service template annotations
The SRE template service_dashboard SHALL put the deploy and incident annotation queries into the annotations.list of every dashboard it builds.
Scenario: Template builds both annotation queries
- WHEN
uv run pytest tests/grafana/test_service_dashboard.py -k annotationruns - THEN the test passes and the built
annotations.listholdssum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0andALERTS{alertstate="firing", severity="critical"}
Requirement: Generated service dashboards
The committed devops-roadmap-service.json and devops-sre-service.json SHALL be the text that make dashboards writes from services.toml.
Scenario: Build reproduces the committed dashboards
- WHEN
make dashboards && git diff --exit-code -- k8s/monitoring/dashboardsruns - THEN the command exits 0 and prints no diff for the two service dashboards
Requirement: CLI dashboard annotations
The devops-cli-telemetry dashboard SHALL hold one non-built-in annotation query for successful Argo CD syncs and one for firing critical alerts.
Scenario: Deployed CLI dashboard holds both queries
- WHEN
uv run devops grafana dashboards export devops-cli-telemetry --output /tmp/devops-cli.jsonruns andjq -r '[.annotations.list[] | select(.builtIn != 1) | .expr]' /tmp/devops-cli.jsonreads the export - THEN the output holds
sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0andALERTS{alertstate="firing", severity="critical"}
Requirement: Only own dashboards change
The change MUST modify no Kubernetes file other than k8s/devops/dashboards/devops-cli.json, k8s/monitoring/dashboards/devops-roadmap-service.json and k8s/monitoring/dashboards/devops-sre-service.json.
Scenario: Upstream dashboards unchanged
- WHEN
git diff --name-only origin/main -- k8s/runs - THEN the output names only those three files
Requirement: Deploy query has data
The deploy annotation query MUST return at least one series over the last 24 hours.
Scenario: Deploy query returns data
- WHEN
uv run devops prometheus query 'sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[24h])) > 0'runs - THEN the output holds one or more series
Requirement: Incident query has data
The incident annotation query MUST return one series for each critical alert that fired in the last 7 days.
Scenario: Incident query returns data
- WHEN
uv run devops prometheus query 'max_over_time(ALERTS{alertstate="firing", severity="critical"}[7d])'runs - THEN the output holds one series for each critical alert that fired in the last 7 days
Requirement: Dashboard lint
The changed dashboards MUST pass devops grafana dashboards lint.
Scenario: Lint reports no defect
- WHEN
uv run devops grafana dashboards lint k8s/monitoring/dashboards k8s/devops/dashboardsruns - THEN the command reports no error
Requirement: Rendered annotation line
A time-series panel of the devops-cli-telemetry dashboard SHALL show a vertical dotted annotation line at a sync time over 24 hours.
Scenario: Rendered panel shows the line
- WHEN the Grafana MCP tool
get_panel_imagerenders one time-series panel ofdevops-cli-telemetryover 24 hours - THEN the image shows a vertical dotted line at a sync time
Requirement: Design gap recorded
The Grafana row of docs/DESIGN.md SHALL state that the text of an annotation shows only on hover, so the deploy and incident lines meet neither the C8 label above the plot nor C11.
Scenario: Grafana row states the hover gap
- WHEN
rg -n 'hover' docs/DESIGN.mdruns - THEN the output shows the Grafana row at line 260 with the hover-only gap against C8 and C11
Existing Tool Considered
grafana/grafana (https://github.com/grafana/grafana), AGPL-3.0, maintained, is in-use: the repository already deploys Grafana. Its alternatives block of 2026-11-19 lists the Lacks: that this change accepts, so they are not restated here. The change adds two annotation queries on the Prometheus data source to k8s/devops/dashboards/devops-cli.json and, through src/devops_cli/grafana/service_dashboard.py, to each generated service dashboard, and records the hover-only gap in the Grafana row of docs/DESIGN.md. No new service, credential or NetworkPolicy change is needed.
Key questions
- Which dashboards receive the deploy and incident annotations?:
k8s/devops/dashboards/devops-cli.json(uiddevops-cli-telemetry) receives them directly, and every service dashboard that the SRE template builds receives them throughsrc/devops_cli/grafana/service_dashboard.py:k8s/monitoring/dashboards/devops-roadmap-service.jsonanddevops-sre-service.json. The dashboards copied from upstream stay as published. The issue'ssre-service.jsonis nowdevops-sre-service.json, anddevops-cli.jsonmoved tok8s/devops/dashboards/. (best practice) [sources: docs/DESIGN.md:260, k8s/devops/dashboards/kustomization.yaml, k8s/monitoring/dashboards/kustomization.yaml]- Chosen: Own dashboards through the CLI file and the SRE template. The CLI dashboard is hand-maintained, and the two service dashboards are the build of the template, so the template is the only place that survives
make dashboards. - Rejected: All dashboards, upstream copies included.
docs/DESIGN.md:260keeps the dashboards copied from upstream as published. - Rejected: Edit only the two service JSON files.
k8s/README.md:344says do not edit the generated dashboards, and the CI job Design Tokens fails when a committed dashboard is not the build.
- Chosen: Own dashboards through the CLI file and the SRE template. The CLI dashboard is hand-maintained, and the two service dashboards are the build of the template, so the template is the only place that survives
- Which source supplies the deploy and incident annotations?: Two Prometheus annotation queries on the
prometheusdata source. The deploy query usesargocd_app_sync_totaland the incident query usesALERTS. The Argo CD Notifications Grafana service is not used. (best practice) [sources: k8s/argocd/values.yaml:18-21, k8s/README.md:314]- Chosen: Prometheus annotation queries. Argo CD's controller metrics reach Prometheus through its ServiceMonitor, and
ALERTSis already in Prometheus, so no new service or credential is needed. - Rejected: Argo CD Notifications Grafana service. It needs an Editor service account, a Secret and two NetworkPolicy changes, as the issue body states.
- Rejected: Built-in Grafana annotations. Grafana stored 0 annotations and no dashboard has a non-built-in query, as the issue body measured.
- Chosen: Prometheus annotation queries. Argo CD's controller metrics reach Prometheus through its ServiceMonitor, and
- Does Argo CD expose its sync counter to Prometheus?: Yes.
k8s/argocd/values.yamlenables the controller metrics and their ServiceMonitor, and Alloy scrapes theargocdcontroller ServiceMonitor and remote-writes to the Prometheus server, soargocd_app_sync_totalhas the labelsnameandphase. [sources: k8s/argocd/values.yaml:18-21, k8s/README.md:314] - Where do the service dashboard annotations come from?:
src/devops_cli/grafana/service_dashboard.pysetsbuilt["annotations"] = {"list": []}at lines 833-841. Replace that empty list with the two queries and runmake dashboards; the committeddevops-roadmap-service.jsonanddevops-sre-service.jsonare its output. (best practice) [sources: src/devops_cli/grafana/service_dashboard.py:833-841, k8s/README.md:344, docs/DESIGN.md:69]- Chosen: Change the SRE template. The two service dashboards are generated, and
make dashboardswrites them; the template is the source that survives the next build. - Rejected: Edit the two JSON files.
k8s/README.md:344says do not edit the JSON, and the Design Tokens job fails when a committed dashboard is not the build. - Rejected: Add a per-spec toggle. Both service dashboards are own dashboards, and feat(grafana): build service dashboards from one SRE template #5184 gives the same queries to each dashboard the template builds, so no spec needs a different value.
- Chosen: Change the SRE template. The two service dashboards are generated, and
- Which properties make each event draw one line?: The deploy query keeps the step
60s, which matches the 60 s scrape interval, adds> 0, which drops the zero-increase samples thatincrease()returns at a step with no sync, and setstitleFormatto{{name}} sync. The incident query setstitleFormatto{{alertname}}, so each line carries the alert name. (best practice) [sources: docs/DESIGN.md:226, k8s/monitoring/k8s-monitoring-values.yaml:12]- Chosen: Step at the scrape interval with
> 0and a title format.increase()returns a sample at every step, and> 0keeps only the step that holds a sync; the 60 s step reads one new scrape, and the title names the Application. - Rejected: The same query without
> 0. A zero increase at each step would draw a line where no sync happened. - Rejected: The built-in Grafana annotation query. Grafana stored 0 annotations, so the built-in query draws no line.
- Chosen: Step at the scrape interval with
- How does the change answer what the tool lacks?: It accepts the
Lacks:list of thein-usealternatives block of 2026-11-19 forgrafana/grafana, and it records the hover-only label gap against C8 and C11 in the Grafana row ofdocs/DESIGN.md. The block itself states the lacks; this proposal does not restate them. (best practice) [sources: docs/DESIGN.md:260]- Chosen: Accept the block's lacks and record the hover gap. The two queries need no credential, and the Grafana row states the gap against C8 and C11, so the dashboard makes no claim of a label above the plot.
- Rejected: Use the Argo CD Notifications Grafana service. It needs a service account, a Secret and two NetworkPolicy changes, which the issue body rejects.
- Which row of
docs/DESIGN.mdrecords the Grafana target rules?: The Grafana row atdocs/DESIGN.md:260, not line 259, which is the Labels row. The row already says the dashboards copied from upstream stay as published. [sources: docs/DESIGN.md:259-260] - How does a person see the rendered annotation line?: The Grafana Image Renderer serves the render API, and the Grafana MCP tool
get_panel_imagetakes a PNG of one panel with the dashboard UID, the panel ID and the theme. [sources: k8s/README.md:377, k8s/README.md:394, k8s/monitoring/grafana-values.yaml:46]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Both work on devops-cli.json, but dan-petty/devops-cli#692 adds CLI telemetry panels while this adds deploy and alert annotation lines.devops-cli-service commentedon Nov 17, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 19, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.