Repository navigation
Description
Update 2026-11-26 (infra move): the environment dashboards moved to dan-petty/homelab.
This issue keeps the 5 linter rules, their tests, the README text, the product dashboards in k8s/devops/dashboards/ and the service dashboard generator (src/devops_cli/grafana/service_dashboard.py), whose burn-rate panels use fixed windows. The environment dashboard fixes are in the homelab follow-up. Do that one before homelab takes the devops-cli release with the new rules.
Follow-up: dan-petty/homelab#277.
Problem or Motivation
The dashboard linter (src/devops_cli/grafana/linter.py, run on each shipped dashboard by tests/grafana/test_grafana_dashboards.py:205) checks only identity, panel ids, layout, datasources and PromQL syntax. It passes every defect of this plan. Measured today: 10 [$__range] targets in time series panels of project-metrics.json; 142 time series targets with a fixed rate or increase window in 8 dashboards (ai-spend 17, coredns 10, devops-cli 48, ingress-tunnel 19, llm-stack 21, otel-collector 8, prometheus-server 6, sre-service 13); 7 time series targets with 'or vector(0)'; histogram_count on seconds axes; by() over labels with no bound.
Proposed Solution & Architectural Design
Add 5 rules to the existing linter: (1) a time series or bar chart target with [$__range] that is not instant; (2) a rate, irate, increase or delta window in a time series target that is not [$__rate_interval] or [$__interval] (a burn-rate window belongs in a recording rule); (3) 'or vector(0)' in a time series target; (4) a by() or legend over a label with no bound (pod, release, workflow, sub_command, run_id, item, branch, host_name, client_ip, user_agent); (5) a histogram_count target in a panel with unit s or ms and no override for that refId. Fix the remaining targets of coredns, ingress-tunnel, otel-collector and prometheus-server in the same pull request ([$__rate_interval]). No exemption list. Write the panel rules in the dashboard section of k8s/README.md.
Target Subsystem
Kubernetes & Minikube Automation (Grafana dashboards and telemetry).
Existing Tool Considered
grafana/dashboard-linter v0.4.0 (Apache-2.0, released 2026-10-21, repository active 2026-11-09). Its target-rate-interval-rule covers only rate() without $__rate_interval. It has no rule for $__range, increase windows, legends, units or 'or vector(0)', and it takes no custom rules. Cost: about 100,000 tokens to build, 3,000 tokens a month to keep, 2 h elapsed.
Acceptance Criteria
- For each rule, a test dashboard makes the linter report an error with the dashboard, the panel and the refId, and a corrected copy lints clean.
- test_repository_dashboards_lint_clean passes for each dashboard of
k8s/devops/dashboards/with no per-file or per-rule exemption. - The new rules add less than 2 s to the test run.
- k8s/README.md lists the 5 rules.
Files
src/devops_cli/grafana/linter.pytests/grafana/test_grafana_dashboards.pyk8s/monitoring/dashboards/coredns.jsonk8s/monitoring/dashboards/ingress-tunnel.jsonk8s/monitoring/dashboards/otel-collector.jsonk8s/monitoring/dashboards/prometheus-server.jsonk8s/README.md
Dependencies
#4684, #4707, #4718, #4712, #4724, #4728, #4732.
Source: #4675
Alternatives check of 2026-11-26: not-applicable.
Class: test, no model call.
Tool: none found.
Proposed design
Problem statement
Add the five dashboard lint rules and fix the product dashboards and the service dashboard generator. The environment dashboards are out of scope and live in the homelab follow-up. The linter checks identity, panel ids, layout, datasources and PromQL syntax only. It passes range variables, fixed rate windows, or vector(0), unbounded labels and histogram_count on a seconds axis.
Acceptance criteria
Requirement: Range variable rule
The linter SHALL report an error when a timeseries, graph or barchart Prometheus target uses $__range and is not instant.
Scenario: Range variable in a graph target
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k range_variableruns on a fixture dashboard whosetimeseriesPrometheus target uses$__rangeand is not instant. - THEN The test passes and the report names the dashboard uid, the panel title and the target refId, and the same target with
$__rate_intervalgives no issue.
Requirement: Range variable off a graph panel
The linter MUST NOT report a range variable error for a stat, table, gauge or heatmap panel.
Scenario: Range variable in a stat panel
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k range_variable_statruns on a fixture dashboard whosestatPrometheus target uses$__range. - THEN The test passes and the report holds no issue for that panel.
Requirement: Fixed window rule
The linter SHALL report an error when a timeseries, graph or barchart Prometheus target has a rate, irate, increase or delta window that is not [$__rate_interval] or [$__interval].
Scenario: Fixed rate window
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k fixed_windowruns on a fixture target that usesrate(http_requests_total[5m]). - THEN The test passes and the report names the dashboard uid, the panel title and the target refId, and the same target with
[$__rate_interval]gives no issue.
Requirement: Constant zero fallback rule
The linter SHALL report an error when a timeseries, graph or barchart Prometheus target contains or vector(0).
Scenario: Constant zero fallback
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k vector_zeroruns on a fixture target that ends withor vector(0). - THEN The test passes and the report names the dashboard uid, the panel title and the target refId, and the same target without the fallback gives no issue.
Requirement: Unbounded label rule
The linter SHALL report an error when a timeseries, graph or barchart Prometheus target groups by, or shows in its legend, one of the ten labels of CONST_GRAFANA_UNBOUNDED_LABELS and holds no positive matcher for that label.
Scenario: Unbounded pod label
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k unbounded_labelruns on a fixture target that groups bypodand holds nopodmatcher. - THEN The test passes and the report names the dashboard uid, the panel title and the target refId, and the same target with
pod=~"$pod"gives no issue, and a label outside the ten gives no issue.
Requirement: Histogram count on a seconds axis
The linter SHALL report an error when a Prometheus target expression contains histogram_count, the panel unit is s or ms, and no field override names the target refId.
Scenario: Histogram count on a seconds panel
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k histogram_count_unitruns on a fixture panel with unitsand a target that containshistogram_count. - THEN The test passes and the report names the dashboard uid, the panel title and the target refId, and a field override for that refId with unit
shortgives no issue.
Requirement: Panels in collapsed rows
The linter SHALL check each panel inside a collapsed row and count it in panel_count.
Scenario: Defect in a collapsed row
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k collapsed_rowruns on a fixture dashboard whose collapsed row holds a panel with a lint defect. - THEN The test passes and the report names the defect with the dashboard, the panel and the refId, and
panel_countincludes the nested panel.
Requirement: Product dashboards lint clean
Each dashboard JSON file under k8s/devops/dashboards/ MUST lint clean with no per-file and no per-rule exemption.
Scenario: Product dashboard lint test
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k test_repository_dashboards_lint_cleanruns over each dashboard JSON file underk8s/devops/dashboards/. - THEN The test passes for every file, and no fixed rate or increase window remains.
Requirement: Service dashboard burn-rate rules
The service dashboard generator SHALL write a Prometheus recording rule for each burn-rate window of each spec and SHALL query the recording rule in the burn-rate chart.
Scenario: Generated service dashboard burn rate
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k service_dashboard_burn_rateruns on a fixtureServiceSpec. - THEN The test passes and the generated dashboard target uses the recording rule metric, and the generated rules file holds the 1 h and 6 h recording rules.
Requirement: Dashboard test runtime
The new rules SHALL add less than 2 s to the dashboard test run.
Scenario: Dashboard lint runtime
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py --durations=0runs. - THEN The lint test of the product dashboards reports a duration under 2 s.
Requirement: Dashboard rules documentation
The dashboard section of k8s/README.md SHALL name each of the five rules and the ten unbounded labels.
Scenario: Rules in the k8s README
- WHEN
uv run pytest tests/grafana/test_grafana_dashboards.py -k rules_documentedruns. - THEN The test passes and the dashboard section of
k8s/README.mdnames the five rules and the ten labels.
Existing Tool Considered
The alternatives check of 2026-11-26 in the issue body records not-applicable (class test, no search) and names no tool. No open, maintained tool covers the need. The issue body records grafana/dashboard-linter v0.4.0 as the one candidate: its target-rate-interval-rule covers only rate() without $__rate_interval, and it has no rule for $__range, increase windows, legends, units or or vector(0), and it takes no custom rules. The proposal adds the five rules to the existing linter and builds no separate linter. The written cost to build and keep the five rules is about 100,000 tokens, 3,000 tokens a month and 2 h elapsed.
Key questions
- Which panel types do rules 1 to 4 apply to, and which panel types does rule 5 apply to?: Rules 1 to 4 apply to
timeseries,graphandbarchartPrometheus targets. Rule 5 applies to each panel type with a Prometheus target. Astat,table,gaugeorheatmappanel gets no range-variable error. (best practice) [sources: src/devops_cli/grafana/linter.py, k8s/devops/dashboards/ai-spend.json]- Rejected: Every rule on every panel type. A non-graph panel such as
Active AI Backendsuses$__rangeon purpose. - Chosen: Graph panels for rules 1 to 4, every panel for rule 5. It matches the measured defects and keeps correct non-graph panels.
- Rejected: Every rule on every panel type. A non-graph panel such as
- What makes a label bound for the unbounded-label rule, and which labels does it check?: The rule checks the ten labels in a new
CONST_GRAFANA_UNBOUNDED_LABELSconstant insrc/devops_cli/config/constants.py:pod,release,workflow,sub_command,run_id,item,branch,host_name,client_ipanduser_agent. A label is bound only by a positive matcher for it in the same target expression, such aspod=~"$pod". Aby()clause or a legend over a label with no such matcher is an error. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/grafana/linter.py]- Rejected: Any by() or legend of the ten labels. It refuses a query that filters
pod=~"$pod"and needs a per-file exemption. - Rejected: A dashboard template variable bounds the label. A template variable is no filter, so the query still returns every series.
- Chosen: A positive matcher in the same target expression. It detects an unbounded series and accepts the query that filters it.
- Rejected: Any by() or legend of the ten labels. It refuses a query that filters
- How does the linter detect a
histogram_counttarget on a seconds axis?: It reports an error when the target expression containshistogram_count, the panel unit issorms, and no field override names the target refId with a count unit. It applies to every panel type. (best practice) [sources: src/devops_cli/grafana/linter.py, src/devops_cli/grafana/schema.py]- Rejected: Panel unit only. It refuses a panel that overrides the unit for the histogram target.
- Chosen: Panel unit plus a refId override. It allows a correct per-target unit override and still catches the defect.
- Should the linter check the panels inside collapsed rows?: Yes. The linter flattens the
panelsof each row recursively before it runs the checks, andpanel_countcounts each nested panel. (best practice) [sources: src/devops_cli/grafana/schema.py:133, src/devops_cli/grafana/linter.py]- Rejected: Leave nested panels unchecked. The generated service dashboards hold panels in collapsed rows, so a rule would skip them and the test would pass a defect.
- Chosen: Flatten row panels before the checks. It applies each rule to each panel with no per-file exemption.
- How does the service dashboard generator avoid fixed burn-rate windows?: The generator writes a Prometheus recording rule for each burn-rate window of each spec and queries the recording rule in the burn-rate chart. The 1 h and 6 h windows stay fixed in the recording rule, not in the dashboard target. (best practice) [sources: src/devops_cli/grafana/service_dashboard.py, k8s/devops/monitoring/prometheus-rules-values.yaml]
- Rejected: Use
$__rate_intervalin the burn-rate chart. It changes the 1 h and 6 h burn-rate window and makes the page lines wrong. - Chosen: Write a recording rule for each burn-rate window. It keeps the 1 h and 6 h windows and passes the fixed-window rule.
- Rejected: Use
- Where does the service dashboard generator write its burn-rate recording rules?: It writes
<uid>-rules.yamlnext to the dashboard file. The file holds a Prometheus rule group with one recording rule for each burn-rate window. (best practice) [sources: src/devops_cli/grafana/service_dashboard.py]- Rejected: Add static rules to k8s/devops/monitoring/prometheus-rules-values.yaml. The file cannot hold a rule for each service spec in homelab.
- Chosen: Write a rules file next to the dashboard. The generator has the selectors of each spec and writes the rules with the dashboard.
- Which dashboards must the lint test cover?: Every dashboard JSON file under
k8s/devops/dashboards/. The test enumerates the files and does not fix a count. [sources: tests/grafana/test_grafana_dashboards.py] - Does the environment freeze block this change?: No. The change edits
k8s/devops/dashboards/,k8s/README.mdandsrc/devops_cli/grafana/. The freeze refuses a non-Markdown file underk8s/outsidek8s/devopsandk8s/overlays/homelab/devops. It allows these paths. The change needs no feat(argocd): read the environment from the homelab repo #5134 step 17. [sources: docs/HOMELAB_REPO_SWITCH.md] - Where do the five rules go in the documentation?: In the dashboard section of
k8s/README.md. The environment freeze allows a Markdown change underk8s/, and the issue names this section. (best practice) [sources: k8s/README.md]- Rejected: docs/guidelines/kubernetes.md. A guideline names no path of an environment tree, and the rules apply to the dashboard files of this tree.
- Chosen: The dashboard section of k8s/README.md. The issue names it, and the freeze allows a Markdown change there.
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(monitoring)scope of the title gives the scope.Catches real defects shipping in dashboards but is a quality gate, not a user-facing fix.Prevents a class of dashboard errors from shipping but does not fix a single user-facing bug.Five new rules, four dashboard fixes, tests, and documentation.Both concern Grafana dashboard query correctness, but #1175 fixes specific broken queries while the candidate adds automated lint rules to catch a class of errors.dan-petty commentedon Nov 12, 2026
A gap found while building #5184:
lint_dashboardreads only the top-level panels (Dashboard.panelsofsrc/devops_cli/grafana/schema.py), so it does not check the panels of a collapsed row. The generateddevops-roadmap-service.jsonanddevops-sre-service.jsonhold their capacity, log and flame graph panels in collapsed rows, anddevops grafana dashboards lintreports 15 panels for each, not 22 or 23.When the linter reads the panels of a collapsed row, a Pyroscope target needs its own rule: the Pyroscope query has
labelSelectorandprofileTypeIdand noexpr, so the empty-query check would refuse it.pyroscope.jsontoday holds an extraexpron each target only for the linter.devops-cli-service commentedon Nov 14, 2026
Alternatives check: not-applicable
Class: test. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Refine cannot set this item to Ready at 699a4ef while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at f771237 (see proposed design in issue body).
8 remaining items
devops-cli-service commentedon Nov 25, 2026
Owner question: See Suspected block and Watched files in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 26, 2026
Owner question: See Suspected block and Watched files in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 26, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 28, 2026
Released in v0.239.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.239.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 20:38 UTC