Repository navigation
feat: Support PromQL dashboard tiles in the external API - #3379
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 1ee91e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Duplicate code analysis3 new clones introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
[Medium impact] The PR appears safe to merge with the verified stack follow-ups; the long-expression save issue is non-blocking.
|
E2E Test Results✅ All tests passed • 446 passed • 1 skipped • 1626s
Tests ran across 4 shards in parallel. |
bbadc0a to
6c6bdbb
Compare
2f074f9 to
3d6c85d
Compare
3d6c85d to
adeba2e
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
| w: 6, | ||
| h: 3, | ||
| config: { | ||
| configType: 'promql', |
There was a problem hiding this comment.
🔵 minor — No integration test covers the REST create, read and save-back path for PromQL tiles or their validation
The only new integration test with a PromQL tile checks alert cleanup. Nothing exercises the main path in the PR description: a PromQL tile surviving GET → PUT, POST with a PromQL heatmap no longer being rejected by the heatmap gate, or a missing or wrong PromQL sourceId being rejected. The unit tests call the converters directly and skip validateDashboardTiles. Fix: add integration tests for a PromQL heatmap POST (expect 200), a GET → PUT round-trip that keeps the tile, and a POST whose sourceId points to a non-PromQL source (expect 400 once the source-kind check is added).
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
4 finding(s): 🔴 0 critical · 🟠 3 major · 🔵 1 minor 1 posted as inline comment(s) on the changed lines. 3 listed below. Findings outside 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. This is an additive, well-tested feature with disciplined type-level handling; the two previously-flagged P1 regressions (alerts left on tiles switched to PromQL, and 🟡 P2 -- recommended
🔵 P3 nitpicks (5)
⚪ Pre-existing (not introduced by this diff)
Reviewers (10): correctness (did not return in window), adversarial, testing, maintainability, project-standards, api-contract, kieran-typescript, previous-comments, agent-native, learnings-researcher. No applicable past learnings were found in Coverage note: The correctness reviewer did not complete within the review window; its logic/edge-case scope overlaps substantially with the completed adversarial and kieran-typescript reviewers, which verified converter exhaustiveness (all 8 display types handled; no implicit 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 |
… alerts Round-trip the tile description and lineInterpolation on PromQL tiles so saving a dashboard back through the external API does not reset them. Delete a tile's alert when it is switched to PromQL, since PromQL tiles cannot be alerted on.
adeba2e to
1ee91e4
Compare
| expression: z.string().max(10000), | ||
| alias: z.string().max(10000).optional(), |
There was a problem hiding this comment.
The new 10,000-character caps reject valid saved PromQL expressions. PromqlSeriesSchema and the chart editor allow longer expressions, and GET returns them unchanged. Saving that response through PUT then fails with 400, even if the caller changed only the dashboard name.
Keep the accepted length consistent with saved tiles, or preserve existing expressions that exceed the new limit. Add a round-trip test with a long label matcher.
Summary
Add PromQL dashboard tiles to the external API (
/api/v2/dashboards), so they can be read, created, and saved back without being lost.configType: "promql"with asourceId, a list ofexpressions(expression,alias, andqueryType/reducerwhere the display type supports them),granularity,legendTemplate, heatmap settings, and the display options the chart editor saves for each display type.expressionsis always a list in the API. The saved tile config allowspromqlExpressionto be either a list or a single expression string (the format before multi-expression support), so a stored string such as"up"is returned as[{ "expression": "up" }].connectionId, unlike raw SQL tiles. The connection is read from the PromQL source at query time, so it is never returned or saved on the tile.validateDashboardTilesnow apply only to builder tiles, so a PromQL heatmap is not rejected for not using a Trace source.configType: "promql".How to test
Read and save back
up) and one other tile.GET /api/v2/dashboards/<id>.main: the PromQL tile is missing fromtiles.configType: "promql".PUT /api/v2/dashboards/<id>with thedataobject from that response.main: the PromQL tile is deleted from the dashboard.Create
POST /api/v2/dashboardswith:{ "name": "PromQL API test", "tiles": [ { "name": "Up", "x": 0, "y": 0, "w": 12, "h": 4, "config": { "configType": "promql", "displayType": "line", "sourceId": "<promql source id>", "expressions": [{ "expression": "up", "alias": "Up" }], "legendTemplate": "{{job}}" } } ] }main: 400,configType must be "sql" or omitted.upseries. Edit the tile and confirm the expression, alias, and legend template are filled in.References