Skip to content

feat(monitoring): mark deploys and alerts on the own dashboards #5261

Open

Description

@dan-petty

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 49 Succeeded syncs and 0 Failed syncs in 24 h. The label name holds 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).

  1. Deploys, with step 60s and titleFormat {{name}} sync:

    sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0
    
  2. Incidents, with titleFormat {{alertname}}:

    ALERTS{alertstate="firing", severity="critical"}
    
  3. 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]' on devops-cli.json and on sre-service.json gives the deploy query and the incident query.
  • git diff --stat origin/main shows no change to a dashboard copied from upstream.
  • The deploy query through the Grafana MCP query_prometheus over 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_image of one time-series panel of devops-cli.json over 24 h shows a vertical line at a sync time.
  • The Grafana row of docs/DESIGN.md states 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 annotation runs
  • THEN the test passes and the built annotations.list holds sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0 and ALERTS{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/dashboards runs
  • 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.json runs and jq -r '[.annotations.list[] | select(.builtIn != 1) | .expr]' /tmp/devops-cli.json reads the export
  • THEN the output holds sum by (name) (increase(argocd_app_sync_total{phase="Succeeded", name=~"devops|llm"}[2m])) > 0 and ALERTS{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/dashboards runs
  • 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_image renders one time-series panel of devops-cli-telemetry over 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.md runs
  • 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 (uid devops-cli-telemetry) receives them directly, and every service dashboard that the SRE template builds receives them through src/devops_cli/grafana/service_dashboard.py: k8s/monitoring/dashboards/devops-roadmap-service.json and devops-sre-service.json. The dashboards copied from upstream stay as published. The issue's sre-service.json is now devops-sre-service.json, and devops-cli.json moved to k8s/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:260 keeps the dashboards copied from upstream as published.
    • Rejected: Edit only the two service JSON files. k8s/README.md:344 says do not edit the generated dashboards, and the CI job Design Tokens fails when a committed dashboard is not the build.
  • Which source supplies the deploy and incident annotations?: Two Prometheus annotation queries on the prometheus data source. The deploy query uses argocd_app_sync_total and the incident query uses ALERTS. 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 ALERTS is 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.
  • Does Argo CD expose its sync counter to Prometheus?: Yes. k8s/argocd/values.yaml enables the controller metrics and their ServiceMonitor, and Alloy scrapes the argocd controller ServiceMonitor and remote-writes to the Prometheus server, so argocd_app_sync_total has the labels name and phase. [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.py sets built["annotations"] = {"list": []} at lines 833-841. Replace that empty list with the two queries and run make dashboards; the committed devops-roadmap-service.json and devops-sre-service.json are 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 dashboards writes them; the template is the source that survives the next build.
    • Rejected: Edit the two JSON files. k8s/README.md:344 says 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.
  • 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 that increase() returns at a step with no sync, and sets titleFormat to {{name}} sync. The incident query sets titleFormat to {{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 > 0 and a title format. increase() returns a sample at every step, and > 0 keeps 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.
  • How does the change answer what the tool lacks?: It accepts the Lacks: list of the in-use alternatives block of 2026-11-19 for grafana/grafana, and it records the hover-only label gap against C8 and C11 in the Grafana row of docs/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.md records the Grafana target rules?: The Grafana row at docs/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_image takes 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

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/monitoring
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    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:

    • open source annotate dashboards with deploys from prometheus metrics, results: 5
    • Grafana annotations prometheus query deploys alerts dashboards, results: 5
    • grafana annotations prometheus datasource expr documentation, results: 5
    • argo cd notifications grafana annotation service retention, results: 5
    • github grafana annotations label above plot hover limitation, results: 5
    • grafana.com docs dashboards annotations query, results: 5
    • grafana annotations feature, results: 5
    • argocd notifications grafana annotations integration, results: 5
    • grafana annotation query prometheus example ALERTS, results: 5
    • kubernetes deploy annotations grafana prometheus argocd sync, results: 5

    Sources:

  7. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  8. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/monitoringsource/agentstatus/readytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions