Repository navigation
Description
Problem Statement
#968 (PR #969, commit decb600 on release/v0.2.25) added Total (Sum) and Average (Mean) targets to thirteen breakdown panels across five dashboards under k8s/monitoring/dashboards/ (GPU Utilisation received Average (Mean) only). Three gaps remain at HEAD:
- The aggregates do not aggregate the lines the panel shows. On CPU Usage by Pod and Memory Working Set by Pod (
sre-service.json, panel ids 7 and 8) and Ingress & Tunnel Pod CPU Usage and Ingress & Tunnel Memory Working Set (ingress-tunnel.json, ids 21 and 22), each per-pod line issum by (pod)(orsum by (namespace, pod)) over containers, butAverage (Mean)isavg(...)over the raw container series, so it is a mean per container, not per pod. Measured cluster-wide on 2026-10-02: mean per container 0.0054 cores against mean per pod 0.0065 cores, about 17% low; 12 of 62 pods run more than one container. GPU Memory Used and GPU Power (llm-stack.json, ids 14 and 15) displaymax by (hostname, gpu, modelName)butTotal (Sum)issum(...)over raw series, which double counts the moment the exporter emits a second series per GPU. The same shape holds on every other in-scope panel: the aggregate re-derives the breakdown's selector instead of aggregating the breakdown. - No styling. No in-scope panel has an override for either aggregate line (
fieldConfig.overridesis[]on the sre, ingress, nodes and pods panels and absent on thellm-stack.jsonpanels; only CPU Usage by container ink8s-views-pods.jsoncarries an unrelatedlimitoverride), so the aggregate lines render as two morepalette-classiclines, distinguishable only by legend text. The "properly labeled" half of feat(telemetry): add properly labeled sum and average lines to service and cluster grafana graphs #968 did not land. - Calls in Flight per Deployment (
llm-stack.json, id 2) was in feat(telemetry): add properly labeled sum and average lines to service and cluster grafana graphs #968's scope and shipped with the breakdown target (refId A) only.
The existing test test_dashboards_contain_properly_labeled_sum_and_average_lines (tests/test_grafana_dashboards.py:524) only checks that the legend strings are present on eight of the thirteen panels; it does not look at the expressions or the overrides, so none of the three gaps fails a test today.
Proposed Solution
- Expressions. Every aggregate line is written as
sum(<base>)oravg(<base>), where<base>is the exact text of the panel's breakdown query (refId A).Total (Sum)is then the sum of the lines shown andAverage (Mean)is their mean. Where the breakdown uses dashboard variables ($namespace/$podinsre-service.jsonandk8s-views-pods.json,$servicein Service Request Rate,$node/$clusterink8s-views-nodes.json), the aggregate inherits them, so narrowing the selection narrows the aggregate.llm-stack.jsonhas notemplatingblock and the ingress CPU/memory panels use hard-coded regex selectors, so those aggregates stay cluster-wide, as their breakdowns are. Onsre-service.json, refId A is the{{pod}} usage/{{pod}} working setline; thelimitandrequesttargets (B, C) are not part of the aggregate. The repository PromQL validator (src/devops_cli/prometheus/promql.py, used by the linter atsrc/devops_cli/grafana/linter.py:114) accepts the wrapped forms, includingsum(sum(...) by (pod))andavg(sum by (api_base) (... * on (model_id) group_left (api_base) ...)). - Styling. Field overrides matched by display name (
matcher.id: "byName") on every in-scope panel:Total (Sum):custom.lineStyle{"fill": "dash", "dash": [...]},custom.lineWidth2,color{"mode": "fixed", "fixedColor": "<light grey>"}Average (Mean): same dash and width,color{"mode": "fixed", "fixedColor": "<amber>"}- No
custom.axisPlacementoverride: both stay on the breakdown's axis. The dashboards already uselineStyle/lineWidthunderfieldConfig.defaults.custom(k8s-views-nodes.json:907-910) and abyNamefixed-colour override (k8s-views-pods.json, CPU Usage by container,limit), so the override property ids follow the same schema. - The exact hex values and dash array are the implementer's choice within "light grey" and "amber"; the test asserts
lineStyle.fill == "dash",lineWidth == 2andcolor.mode == "fixed", not specific values. The fixed colours only need to read as reference lines againstpalette-classic.
- Calls in Flight. Add
Total (Sum)(refId B) andAverage (Mean)(refId C) to Calls in Flight per Deployment assum(<A>)/avg(<A>), with the same overrides. GPU Utilisation keepsAverage (Mean)only, since a sum of percentages is meaningless; its expression becomesavg(<A>). - Test. Replace the legend-only check in
test_dashboards_contain_properly_labeled_sum_and_average_lineswith an invariant over every in-scope panel (all fourteen are top-level panels, none sits inside a row): theTotal (Sum)expression equals"sum(" + <refId A expr> + ")", theAverage (Mean)expression equals"avg(" + <refId A expr> + ")", GPU Utilisation has noTotal (Sum), and each panel's overrides contain abyNamematch for each aggregate present withlineStyle.fill == "dash",lineWidth == 2,color.mode == "fixed"and nocustom.axisPlacementproperty. No lint rule insrc/devops_cli/grafana/linter.py: other dashboards may legitimately aggregate differently. - Vocabulary. Add a Telemetry section to
CONTEXT.md(none exists at HEAD; the file has Release planning, Roadmap jobs and Code review) defining Breakdown panel (a time-series panel whose refId A splits one metric by a label) and Aggregate line (aTotal (Sum)orAverage (Mean)target that sums or averages the breakdown's lines), with_Avoid_: baseline, overlay, summary line, reference line. - Rollout. Apply the dashboard ConfigMaps (
kubectl apply -k k8s/, which reachesk8s/monitoring/dashboards/kustomization.yamlthroughk8s/kustomization.yaml:11) after merge, as feat(telemetry): add heatmap and ratio-based graphs to sre dashboards #938 and feat(telemetry): add properly labeled sum and average lines to service and cluster grafana graphs #968 did. The five touched files are ingrafana-k8s-global-dashboards,grafana-k8s-node-dashboardsandgrafana-stack-dashboards;tests/test_k8s_monitoring_dashboards.py::test_each_configmap_fits_kubectls_last_applied_annotationkeeps each under 262,144 bytes.
Scope
The same five dashboards and thirteen panels as #968, plus Calls in Flight per Deployment (fourteen panels):
sre-service.json: CPU Usage by Pod (id 7), Memory Working Set by Pod (id 8)ingress-tunnel.json: Service Request Rate (id 16), Ingress & Tunnel Pod CPU Usage (id 21), Ingress & Tunnel Memory Working Set (id 22)k8s-views-nodes.json: CPU usage by Pod (id 26), Memory usage by Pod (id 28)k8s-views-pods.json: CPU Usage by container (id 29), Memory Usage by container (id 51)llm-stack.json: Calls in Flight per Deployment (id 2), Requests per Deployment (id 4), GPU Utilisation (id 13, Average only), GPU Memory Used (id 14), GPU Power (id 15)
Key Questions (answered)
- Aggregate over raw samples or over the displayed lines? Displayed lines.
- Follow the dashboard variables or stay cluster-wide? Follow the variables. Panels whose breakdown has no variables stay cluster-wide, matching their breakdown.
- Average on throughput panels too? Yes, uniformly on every in-scope panel.
- Total on its own axis? No, same axis. Total dominating the scale on busy panels is accepted over a second axis that invites misreading.
- Lint rule or test? Test on the in-scope panels only.
Acceptance Criteria
- For each in-scope panel, the
Total (Sum)expression issum(<refId A expression>)and theAverage (Mean)expression isavg(<refId A expression>), character for character; GPU Utilisation hasAverage (Mean)only. Shown byuv run pytest tests/test_grafana_dashboards.py -k properly_labeled_sum_and_average. - Calls in Flight per Deployment has both aggregate lines. Shown by the same test.
- Each in-scope panel has
byNameoverrides for each aggregate line present:custom.lineStyledashed,custom.lineWidth2,color.modefixed, nocustom.axisPlacement. Shown by the same test. -
devops grafana dashboards lint k8s/monitoring/dashboardsreports 0 errors and 0 warnings (tests/test_grafana_dashboards.py::test_repository_dashboards_lint_clean);uv run pytest tests/test_stack_dashboards.py tests/test_k8s_monitoring_dashboards.pypasses (exporter coverage and ConfigMap size);uv run devops cipasses. -
CONTEXT.mdhas a Telemetry section defining Breakdown panel and Aggregate line with an_Avoid_line. Shown bygrep -n "Breakdown panel\|Aggregate line" CONTEXT.md. - Pending a person: after merge,
kubectl apply -k k8s/and open each of the five dashboards; every in-scope panel shows the two (or one) dashed aggregate lines on the breakdown's axis, and narrowing$podon SRE Service Performance movesTotal (Sum)with the selection.
Out of Scope
- The same-shaped breakdown panels in
k8s-views-namespaces.jsonandk8s-views-global.json. They become a separate candidate if wanted. - A linter rule for aggregate lines in
src/devops_cli/grafana/linter.py. - Rewording the shipped feat(telemetry): add properly labeled sum and average lines to service and cluster grafana graphs #968 task file and changelog fragment.
- Project metrics gauges and the velocity dashboard (fix(telemetry): the project velocity dashboard reads the latest snapshot of each gauge, and the project gauges drop the _total suffix #974).
Dependencies
- fix(telemetry): the project velocity dashboard reads the latest snapshot of each gauge, and the project gauges drop the _total suffix #974 (backlog, moved out of v0.2.26 with this item on 2026-10-02): shares the new
CONTEXT.mdTelemetry section; whichever merges first creates it and the other rebases to add its own terms (Project metrics, Command telemetry) under the same heading. Additive, no ordering fixed between the two; fix(telemetry): the project velocity dashboard reads the latest snapshot of each gauge, and the project gauges drop the _total suffix #974 touchesproject-metrics.json, not the five dashboards here. - chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842 (v0.2.27): also adds
CONTEXT.mdentries (Gate, Check, Required check) in a different section; additive, a trivial rebase at most. - No item depends on this one, and nothing is required before it: it is low effort and Ready. A person plans its milestone on the board.
Update 2026-10-08: refinement
Still true for panels 2, 7 and 8 and the legend-only test (tests/test_grafana_dashboards.py:524). New: rolling lines on llm-stack.json panels 4, 13 and 14, and panel 17, none built from refId A. (proposed) Each rolling line is the 30-minute mean of its aggregate, such as avg_over_time(avg(<A>)[30m:]); panel 17 drops Total (Sum).
- The same test checks every rolling expression and panel 17.
Proposed design
Problem statement
The telemetry dashboards contain aggregate lines (Total Sum and Average Mean) that do not correctly aggregate the displayed breakdown lines. Specifically, on several panels, the sum and average calculations use raw container series instead of the per-pod breakdown shown in the panel, leading to incorrect values. Additionally, these aggregate lines lack proper styling and one panel is missing its aggregate lines entirely.
Acceptance criteria
- Criterion 1: Each aggregate line expression correctly aggregates the breakdown's lines by using the exact text of the panel's refId A query
Verification: Runuv run pytest tests/test_grafana_dashboards.py -k properly_labeled_sum_and_averageand verify that for each in-scope panel, the Total (Sum) expression equals "sum()" and Average (Mean) equals "avg()" - Criterion 2: Aggregate lines are properly styled with dashed line style, specific line width, and fixed color
Verification: Run the same test and verify that each panel's overrides contain a byName match for each aggregate line present with custom.lineStyle.fill == "dash", lineWidth == 2, color.mode == "fixed", and no custom.axisPlacement property - Criterion 3: The Calls in Flight per Deployment panel has both Total (Sum) and Average (Mean) aggregates
Verification: Run the test and verify that Calls in Flight per Deployment panel shows both aggregate lines - Criterion 4: Dashboard linting passes with no errors or warnings for all affected dashboards
Verification: Rundevops grafana dashboards lint k8s/monitoring/dashboardsand ensure it reports 0 errors and 0 warnings - Criterion 5: CONTEXT.md contains a Telemetry section defining Breakdown panel and Aggregate line terms
Verification: Rungrep -n "Breakdown panel\|Aggregate line" CONTEXT.mdand verify both terms are defined with an Avoid line
Key questions
None.
Open questions
- Should the aggregates be calculated over raw samples or over the displayed lines? (missing verified source)
- Should the aggregates follow dashboard variables or stay cluster-wide? (missing verified source)
- Should average be applied to throughput panels too? (missing verified source)
- Should the total be on its own axis? (missing verified source)
- Should there be a linter rule or test for aggregate lines? (missing verified source)
- Aggregate over raw samples or over the displayed lines? Displayed lines.
- Follow the dashboard variables or stay cluster-wide? Follow the variables. Panels whose breakdown has no variables stay cluster-wide, matching their breakdown.
- Average on throughput panels too? Yes, uniformly on every in-scope panel.
- Total on its own axis? No, same axis. Total dominating the scale on busy panels is accepted over a second axis that invites misreading.
- Lint rule or test? Test on the in-scope panels only.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Linked: #821. Both edit the GPU row of
k8s/monitoring/dashboards/llm-stack.json(row 12, panels 13-17); whichever lands second rebases. Found by the 2026-10-08 backlog review.fix(telemetry): grafana aggregate lines sum and average the lines sho…