grafana/metrics-drilldown

bug: hardcoded legendFormat carried into Explore causes duplicate series names

Open

#1,248 opened on May 12, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (12 forks)github user discovery
good first issue

Repository metrics

Stars
 (27 stars)
PR merge metrics
 (PR metrics pending)

Description

What happens

Opening a metric panel in Explore from Drilldown carries over a hardcoded legend. The series end up looking wrong or confusing (e.g. multiple series sharing the same name after a query edit), and the legend setting is collapsed by default in Explore so he user has no clear way to understand why or fix it.

Where the legendFormat is set

  • src/shared/GmdVizPanel/types/timeseries/getTimeseriesQueryRunnerParams.ts
  • src/shared/GmdVizPanel/types/stat/getStatQueryRunnerParams.ts
  • src/shared/GmdVizPanel/types/percentiles/getPercentilesQueryRunnerParams.ts
  • src/shared/GmdVizPanel/types/statushistory/getStatushistoryQueryRunnerParams.ts

Where the link is built

src/MetricScene/PanelMenu/actions/ExploreAction.ts calls getExploreURL(panelData, ..., (query) => ...). The current transform callback only strips __ignore_usage__ from expr.

Proposed fix

Strip legendFormat in the ExploreAction transform callback so the Explore URL does not carry Drilldown's hardcoded legend, while leaving Drilldown's own panels untouched.

Repro

  1. Open a metric in Drilldown (no group-by).
  2. Panel menu → Explore.
  3. In Explore, edit the query to add by (some_label).
  4. Observe all series in the legend share the same name (e.g. avg).
  5. Expand Options → Legend and clear the field — series names now render correctly from labels.

Contributor guide