fix(grafana): resolve multi-target legend collisions and aggregation-scope mismatches (#354, #355) - #364
Open
giorgi-imerlishvili-elastic wants to merge 1 commit into
Conversation
…scope mismatches (elastic#354, elastic#355) Fused multi-target XY panels previously mislabelled every series with the first target's literal legendFormat text when templates disagreed (issue elastic#354), and union-grouped a bare aggregation (no `by()`) into a grouped sibling's BY fields instead of reproducing Grafana's single cross-series line (issue elastic#355). Both silently changed panel semantics rather than degrading gracefully with a warning. - Suppress the composite legend expression when fused targets carry different multi-placeholder legendFormat templates, so the STATS column name carries series identity instead. - Split a same-metric bare/grouped pair into two ES|QL layers (reusing the cross-index-layer XY shape) so the bare aggregate is computed across every series instead of per-group; keeps today's union behavior for bare targets that broadcast an unrelated metric, and applies the split inside each index partition of a cross-index panel. - Preserve a lone bare target's own static legend text as its layer's column alias, and prevent that legend from leaking onto the grouped layer's identity when the bare target is listed first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two Grafana translator issues where fused multi-target XY panels silently changed panel semantics instead of degrading gracefully:
legendFormattemplates, the compositeEVAL legendexpression mislabelled every series with the first target's literal text. The composite legend is now suppressed in that case so theSTATScolumn name carries series identity instead; targets whose templates agree, or that use only a single placeholder, are unaffected.byare grouped per-series, so Min/Avg/Max become per-series duplicates #355 — Aggregation-scope mismatch. A bare aggregation (noby(), e.g.min/avg/max/sum) sharing its metric field with a grouped sibling target (the disk-graphs "IO Wait per core" Min/Avg/Max-over-CPUs shape) was union-grouped into the sibling'sBYfields, turning a single cross-series line into per-group duplicates. It now renders as two separate ES|QL layers — reusing the existing cross-index-layer XY shape — so the bare aggregate is computed across every series, matching what Grafana always draws.Additional refinements found and fixed during code review:
by (qos_class)+ an ungrouped fleet-wide total) no longer disables the split for a different, same-metric bare/grouped pair sharing the same panel — the warning now also names the changed semantics for the unrelated case instead of only describing the mechanism.legendFormattext is preserved as its layer's column alias (instead of falling back to the raw metric field name), and no longer leaks onto the grouped layer's identity when the bare target happens to be listed first among the fused targets.docs/sources/grafana.mdis updated to describe the new legend-suppression and layer-split behavior, including the unrelated-bare-target and cross-index-partition cases.Test plan
make test— 5749 passed, 3 skippedmake lint— cleanmake typecheck— cleantests/test_grafana_issues_354_355.py(legend suppression, aggregation-scope split, unrelated-bare-target handling, order-independence, singleton bare-layer legend), plus a cross-index regression intests/core/metric_mapping/test_cross_index_xy_layers.pyand an updated warning-message assertion intests/test_grafana_qos_union_by.py.