Skip to content

fix(grafana): translate named seriesOverrides stack groups - #450

Merged
shmsr merged 1 commit into
elastic:mainfrom
stefans-elastic:fix/grafana-named-seriesoverride-stack-groups
Sep 22, 2026
Merged

shmsr merged 1 commit into
elastic:mainfrom
stefans-elastic:fix/grafana-named-seriesoverride-stack-groups

Conversation

@stefans-elastic

Copy link
Copy Markdown
Collaborator

Closes #446

Summary

Grafana's seriesOverrides[].stack is tri-state: false, true, or a group name ("A", "B", "D"…). Only false was honored, so a named group fell through and a series Grafana draws as a separate overlay got accumulated onto the stacked breakdown it is meant to sit above.

The case

Dashboard 9852's Memory panel:

{"alias": "/Total memory/", "color": "#bf1b00", "fill": 0, "linewidth": 2, "stack": "D"}

Grafana stacks active+buffers+cached to 6.46 GB and draws Total memory as its own unfilled line at 6.20 GB. The migration stacked all four:

Grafana Kibana (before)
stacked band 6.46 GB 6.45 GB
overlay line 6.20 GB 6.20 GB
chart maximum 6.46 GB 12.65 GB

Every individual series value was already correct — only the stacking composition was wrong, which makes a side-by-side look like a data discrepancy when it isn't.

Approach

A named group holding exactly one series is an unstacked overlay, and it maps losslessly onto machinery that already existed end-to-end:

  • the panel schema documents per-metric stack — "rendered as an unstacked overlay"
  • the Kibana target already emits a stacked layer plus an unstacked overlay layer (dashboards_api.py, commented "kubernetes-mixin style: stack usage by breakdown, overlay requests/limits unstacked")

Only the source-side mapping was missing. Resulting Memory panel:

Lens layer Series
area_stacked Memory active, Memory buffers, Memory cached
line Total memory

Groups with 2+ members are disclosed, not reshaped. Lens accumulates one stack per layer, so several independent stacks cannot be represented; those stay stacked and emit a warning rather than being silently restructured.

Reviewer note

The fix only takes effect when the series name matches the override alias. 9852's alias is the regex /Total memory/ (with a space) while default naming yields Total_memory (underscore), so it matches there only because the curated pack renames the series. Underscore-vs-space alias matching for un-packed dashboards is a separate gap, flagged at the end of #446 — not addressed here.

Test plan

  • test_named_stack_group_singleton_becomes_unstacked_overlay — singleton → overlay, siblings stay stacked, and the native output carries both an area_stacked and an unstacked layer
  • test_named_stack_group_with_multiple_series_is_disclosed_not_reshaped — 2-member group stays stacked and surfaces a disclosure
  • make test 6390 passed, 61 skipped; make lint and make typecheck clean
  • Verified in a browser against Grafana: chart maximum 6.45 GB vs Grafana's 6.46 GB

🤖 Generated with Claude Code

Grafana's seriesOverrides[].stack is tri-state: false, true, or a group name
("A", "B", "D"...). Only false was honored, so a named group fell through and a
series Grafana draws as a separate overlay was accumulated onto the stacked
breakdown it is meant to sit above.

Dashboard 9852's Memory panel is the case: {"alias": "/Total memory/",
"fill": 0, "stack": "D"} makes Grafana stack active+buffers+cached to 6.46 GB
and draw Total memory as its own unfilled line at 6.20 GB. The migration
stacked all four, so the chart maximum read 12.65 GB -- roughly twice too tall,
while every individual series value was correct.

A named group holding exactly one series is precisely an unstacked overlay, and
it maps losslessly onto the per-metric `stack` the panel schema already carries
("rendered as an unstacked overlay") and the Kibana target already renders as a
separate layer (dashboards_api.py, kubernetes-mixin style stacked breakdown plus
unstacked overlay). Only this source-side mapping was missing.

Kibana Lens accumulates one stack per layer, so a named group holding two or
more series cannot be represented. Those stay stacked and are disclosed as a
warning rather than silently reshaped.

Note the fix only takes effect when the series name matches the override alias.
9852's alias is the regex /Total memory/ (with a space) while default naming
yields Total_memory, so it matches there only because the curated pack renames
the series; underscore-vs-space alias matching is a separate gap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grafana: named seriesOverrides stack groups are dropped, stacking an overlay series onto the breakdown

2 participants