elastic / elastic/observability-migration-platform
[Datadog] top()/bottom() ranking query wrapper not parsed -> whole panel degraded ("metric query could not be parsed")
- Dominant language
- Python
- Stars
- 6
- Forks
- 8
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 23
Description
## Summary
A Datadog query wrapped in `top(...)`/`bottom(...)` (a standard ranking wrapper) fails to parse, so the entire panel is degraded to a `requires_manual` markdown placeholder with "metric query could not be parsed", instead of translating the ranking or at least plotting the inner series.
## Affected dashboard(s)
- `istio` (`istio/assets/dashboards/istio_1_5_openmetrics_overview.json`) — panel **"Heap in use (percent)"**. Affects any widget whose query is wrapped in `top()`/`bottom()`.
## Environment
- `obs-migrate` files mode, `--field-profile otel`, `--data-view metrics-*`.
- Target: local Kibana **9.5.0** (build 105158, snapshot) / Elasticsearch **9.5.0-SNAPSHOT**.
## Reproduction
1. Migrate the Istio v1.5+ OpenMetrics overview dashboard; open "Heap in use (percent)".
## Expected
`top(avg:metric{...}, 10, 'mean', 'desc')` should translate (e.g. ES|QL `... | SORT ... | LIMIT 10`, the same ranking already applied for XY formulas) or at least plot the inner series.
## Actual
Panel degrades to a `requires_manual` placeholder; `reasons=["metric query could not be parsed"]`, `warnings=["query syntax not recognized; manual review needed"]`, no ES|QL emitted. Source queries:
```
top(avg:istio.go.memstats.heap_inuse_bytes{$cluster}, 10, 'mean', 'desc')
top(avg:istio.go.memstats.heap_alloc_bytes{$cluster}, 10, 'mean', 'desc')
```
## Evidence
## Suspected root cause
The metric-query parser does not recognize a top-level `top(...)`/`bottom(...)` wrapper around a metric query. (`_extract_top_params` handles `top()` inside an XY *formula* AST, but not a raw query-string wrapper.) Supporting the wrapper — or stripping it and plotting the inner query — would migrate the panel.
Contributor guide
Research direction
Start with the metric-query parser and its _extract_top_params handling, then reproduce the Istio dashboard migration for the “Heap in use (percent)” panel. Compare the raw top()/bottom() query path with the XY formula path. Done means the ranking is translated or the inner series is plotted, without a requires_manual placeholder or parse warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100