Skip to content

feat(grafana): build service dashboards from one SRE template #5184

Closed
1 of 1 issue completed
Closed

Description

@dan-petty

Problem or Motivation

The 16 dashboards in k8s/monitoring/dashboards/ are hand-written JSON (devops-cli.json is 80 KB). docs/DESIGN.md sets the SRE layout (the paragraph "Grafana layout" and the rules C2, C4, C5, C7, C8, C12 and C14) and the Grafana colors for the light and the dark theme, but only as text. Each dashboard applies the rules by hand, and the dashboards drift from them:

On 2026-11-12 the owner asked for one template for the dashboards of Kubernetes services that applies the SRE rules, in the light and the dark theme, with the same look as the start page, the docs site and the reports (#4735).

Proposed Solution & Architectural Design

  • A build-time Python module makes the dashboard JSON with the Grafana Foundation SDK (grafana-foundation-sdk on PyPI, Apache-2.0, Grafana Labs, release 0.0.22 on 2026-10-29). The SDK goes in a dependency group, not in the runtime dependencies.
  • One function makes a service dashboard from a service spec: title, uid, namespace, workload, the request, error and latency metrics, the SLO target and window, and the saturation sources. For a service behind the ingress, the default request metrics are the Traefik service metrics (traefik_service_requests_total and traefik_service_request_duration_seconds, live on 2026-11-12). The first spec uses an SLO of 99.9 % over 30 days (DESIGN.md C12) and the pull request asks the owner to confirm it.
  • The layout is the "Grafana layout" of DESIGN.md: row 1 the 4 SLO tiles (w6 h4); row 2 the burn rate (1 h against 14.4x, 6 h against 6x, and the 1x pace) and the budget left (w12 h8 each); row 3 the golden signals in the order latency, traffic, errors, saturation (w12 h8); then collapsed rows for capacity (use, request and limit), logs (Loki) and profiles (Pyroscope) when the service has them.
  • The service specs are in one file next to the dashboards. A Make target writes k8s/monitoring/dashboards/<uid>.json. The generated JSON stays in git, and Argo CD provisions it as now. The CI job "Design Tokens" (its path filter holds k8s/monitoring/dashboards/) fails when a committed dashboard is not the build.
  • Light and dark. The dashboards keep the theme of the viewer (the Grafana default theme is system). The template reads its colors from the token build and holds no color literal: series 1 and 2 use the hex values of color.data.cat.1 and color.data.cat.2, which pass 3:1 on the four Grafana backgrounds (#ffffff, #f4f5f5, #181b1f, #111217); a third entity and the baselines use the Grafana color text; the states use text, semi-dark-orange and red; heatmaps use continuous-cividis; reference lines are constant queries with the line style dots (C14). If the token build has no output that Python can read, add one to the Style Dictionary config.
  • The first outputs: the dashboard of the roadmap Service (the layout that feat(roadmap): a dashboard and alerts for the pipeline #3655 needs; if feat(roadmap): a dashboard and alerts for the pipeline #3655 merges first, its dashboard moves to the template), and the generic service dashboard that replaces sre-service.json with the variables namespace and workload (fix(monitoring): open the SRE dashboard on the Service namespace #4728 then applies to the template).

Target Subsystem

Grafana dashboards (k8s/monitoring/dashboards/), the design tokens (design/, src/devops_cli/design/).

Existing Tool Considered

  • Grafana Foundation SDK (chosen): typed builders for Python from Grafana Labs, maintained.
  • grafonnet: Jsonnet, so a second language and toolchain in a Python project.
  • grafanalib: no release since 2024-01-12, and its owner Weaveworks closed. Not maintained.
  • Grafana library panels: stored in the Grafana database, not in git. The cluster is GitOps (Argo CD prune and self-heal).
  • Sloth and Pyrra: they make SLO recording and alert rules, not this layout. Consider them for the alert rules of feat(roadmap): a dashboard and alerts for the pipeline #3655; out of scope here.

Feasibility to confirm first: the SDK release whose dashboard schema agrees with Grafana 13.3.1 (live, /api/health), and that its JSON is the classic dashboard JSON that the dashboard sidecar provisions.

Acceptance Criteria

  • Unit tests on a fixture spec: the row order and the grid positions of the DESIGN.md layout; each panel has one unit, a title in sentence case and a description; no time series has more than 3 series plus "Other"; the burn-rate panel has y min 0, unit x and the page lines 14.4 and 6.
  • A test fails when the generated JSON holds a color that is not a token hex that passes 3:1 on the four Grafana backgrounds, or not a Grafana color name from the DESIGN.md list.
  • Harness cases (test(monitoring): evaluate panel queries on fixture series #4680) for the SLI and the burn rate: 1,000 requests with 2 errors and an SLO of 99 % give an SLI of 0.998, 80 % of the budget left and a burn rate of 0.2x.
  • CI fails when a committed generated dashboard is not the build.
  • A pull request comment holds screenshots of the generated Service dashboard in the Grafana light theme and the dark theme, with 24 h of live data (the image renderer item, or a headless browser).
  • DESIGN.md names the template in the row "Grafana" of "Rules for each target".

Related

#4735 (parent), #4675, #4707, #4718, #4762, #3655, #4728, #4743.

Source: #4735

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

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

    @dan-petty
    OwnerAuthor
    • Scope: none. The title has the scope grafana, and .github/labels.yml declares no scope/grafana label. Add the label to the file to give the scope to this item.
    • Related: fix(monitoring): open the SRE dashboard on the Service namespace #4728, which asks for a different change. Both target the SRE service dashboard, but #4728 fixes its namespace default while the candidate builds a template system that replaces it.
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  6. removed
    status/in-review
    on Nov 12, 2026
  7. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-13 00:46 UTC

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/highpriority/p2-mediumsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions