Repository navigation
Description
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:
devops-cli.jsonputs counts on a seconds or ms axis in 5 panels, draws 14 to 126 lines in one panel, and has no golden-signal row (fix(monitoring): track readable project dashboards #4675, fix(monitoring): make the GitHub and command panels readable #4707).sre-service.json("SRE / Service Performance & Logs") has no SLO row and does not show the golden signals in the order of the book.- Grafana holds 0 library panels (
/api/library-elements, 2026-11-12), so no panel is shared.
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-sdkon 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_totalandtraefik_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 h8each); 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 holdsk8s/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 ofcolor.data.cat.1andcolor.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 colortext; the states usetext,semi-dark-orangeandred; heatmaps usecontinuous-cividis; reference lines are constant queries with the line styledots(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.jsonwith 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
xand 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
Activity
dan-petty commentedon Nov 12, 2026
grafana, and .github/labels.yml declares no scope/grafana label. Add the label to the file to give the scope to this item.Both target the SRE service dashboard, but #4728 fixes its namespace default while the candidate builds a template system that replaces it.devops-cli-service commentedon Nov 13, 2026
Released in v0.125.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.125.0
devops-cli-service commentedon Nov 13, 2026
Live since 2026-11-13 00:46 UTC