Repository navigation
feat: Support PromQL pie/bar charts - #3253
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 303cfd9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysis2 new clones introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
| // A PromQL range query's rows are buckets, reduced on read; an instant | ||
| // query's are one value per series. Neither can stand in for the other, | ||
| // so switching between them shows the loading state instead. | ||
| placeholderData: (prev, prevQuery) => { |
There was a problem hiding this comment.
🔵 minor — Range/instant placeholder guard only covers pie/bar; the PromQL number tile still flashes a wrong value
Move this check into useQueriedChartConfig (packages/app/src/hooks/useChartConfig.tsx), where select/reducesRangeBuckets is decided, so every caller gets it. DBNumberChart (packages/app/src/components/DBNumberChart.tsx:242) still uses placeholderData: prev => prev. So when a number tile switches from range to instant, the raw bucketed rows are shown with no reducer, and the tile displays the first bucket of the first series until the fetch finishes. The same gap exists here when the previous key is a builder config: those rows go through reduceBucketRows and briefly show 'No data found'.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
1 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 0 minor 1 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. The prior P1 concern ("instant matrices produce duplicate categories") is resolved by this diff: 🟡 P2 -- recommended
🔵 P3 nitpicks (1)
Reviewers (6): correctness, maintainability, project-standards, performance, julik-frontend-races, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
|
E2E Test Results✅ All tests passed • 391 passed • 1 skipped • 1166s
Tests ran across 4 shards in parallel. |
6cef43c to
012e815
Compare
jordan-simonovski
left a comment
There was a problem hiding this comment.
Looks awesome!
| displayType?: DisplayType; | ||
| }): boolean => | ||
| isReducibleRangeQuery(config) && | ||
| displayTypeSupportsReducer(config) && |
There was a problem hiding this comment.
🟠 major — Existing instant number tiles with a saved reducer now silently change value (Count turns every series into 1)
formPromqlExpressions (packages/app/src/components/ChartEditor/utils.ts:512-517) has always saved reducer on Number tiles whatever the query type. Before this PR, appliesPromqlReducer ignored that reducer on instant queries. A tile that was set to Range + Count and later switched to Instant still stores reducer: Count, and with this change it will show 1 instead of the real value. The e2e step in promql-number.spec.ts confirms this: Instant + Count gives '1'. Fix: when the instant result is a plain vector (isBucketed: false, one sample per series), skip the reducer. Alternatively, drop or migrate stale reducers on instant number tiles, or hide Count for instant queries.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
Summary
Add support for PromQL pie charts and bar charts. Both range queries (with a reducer) and instant queries are supported. The legend template is supported as well.
This PR also extends support for reducers to instant queries. Instant queries like
up[5m]return matrix type results, which can be reduced (over the time dimension) to instant vectors, which are then shown as the pie chart slices or bar chart bars. This impacts the number chart as well, where the reduced value is shown as the number value.Screenshots or video
How to test locally
References