Skip to content

feat: Support PromQL heatmaps (series-mode) - #3313

Merged
kodiakhq[bot] merged 12 commits into
mainfrom
drew/heatmap-promql-series
Oct 7, 2026
Merged

kodiakhq[bot] merged 12 commits into
mainfrom
drew/heatmap-promql-series

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for PromQL heatmaps in "series-mode" where the y-axis is the series.

Macros, variables, and legend templates work as expected. The query is range-only.

Screenshots or video

Screenshot 2026-10-07 at 9 45 00 AM

How to test locally

  1. Setup a promql source on metrics_ts
  2. Create a heatmap visualization using the new source. Try different granularities, expressions, variables, macros, and legend templates.

References

  • Linear Issue: Closes HDX-5608
  • Related PRs:

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
hyperdx-oss Ignored Ignored Preview Oct 7, 2026 7:04pm UTC
hyperdx-storybook Ignored Ignored Preview Oct 7, 2026 7:04pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e1e4de9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Minor
@hyperdx/api Minor
@hyperdx/otel-collector Minor

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

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 0 minor

None could be anchored to changed lines; they are listed below.

Findings outside the changed lines

  • 🟠 packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:822 — Switching a heatmap between Builder and PromQL wipes the builder series → Heatmaps now show the Builder/PromQL toggle (configTypeOptions), which opens a path that wasn't reachable before. Toggling the config type triggers the displayType/configType effect (EditTimeChartForm.tsx:801-849). For a Heatmap that effect always calls applyHeatmapDefaults. Going to PromQL forces heatmapMode to 'series', so select/series get reset to count with an empty value expression, and the duration number format is cleared. Coming back to Builder, tableSource is still the PromQL source and fallbackValueExpression is now '', so the user's value expression, count expression, conditions and scale type are lost. A trace source with a duration expression only gets its default duration expression back. Fix: only apply heatmap defaults when displayTypeChanged, or skip that branch when configTypeChanged && configType === 'promql'. Add a test that toggles Builder→PromQL→Builder on a heatmap and checks the series is kept.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The two P1 items raised in earlier review rounds are both verifiably addressed in the current diff: isPromqlDisplayType once again includes DisplayType.StackedLine (so existing PromQL stacked-line charts still open in the PromQL editor), and the new queryPromqlChartConfig heatmap test passes {} as the required attribution argument. The PromQL-heatmap data flow is internally consistent — a DisplayType.Heatmap PromQL config resolves to series mode, keeps all expressions through buildHeatmapSeriesConfig, preserves its display type through convertToTimeChartConfig, and is correctly narrowed to a single range-queried expression by getQueriedPromqlSeries.

🟡 P2 — recommended

  • packages/app/src/components/DBHeatmapChart/heatmapQueries.ts:138 — The "only the first expression is queried" guarantee for multi-expression PromQL heatmaps is only tested via a direct queryPromqlChartConfig call; no test exercises the buildHeatmapSeriesConfig → convertToTimeChartConfig path with multiple expressions, so a future change that rewrote the preserved displayType away from Heatmap would silently render extra series uncaught.
    • Fix: Add a test asserting a multi-expression PromQL heatmap routed through buildHeatmapSeriesConfig resolves to a config that still queries only the first expression.
🔵 P3 nitpicks (2)
  • packages/app/src/components/DBHeatmapChart/heatmapQueries.ts:1 — The file is now 305 lines, just over the packages/app/AGENTS.md "keep files under 300 lines" guideline.
    • Fix: Extract a small cohesive helper (e.g. the series-config builders) into a sibling module to drop back under the limit.
  • packages/app/src/components/ChartEditor/utils.ts:190 — isPromqlDisplayType is now a hand-maintained explicit display-type list that duplicates most of isRawSqlDisplayType; the two can silently drift as new display types are added.
    • Fix: Derive the shared portion from a single source list, or add a comment pinning the two lists' relationship.

Reviewers (10): correctness, adversarial, kieran-typescript, testing, maintainability, project-standards, julik-frontend-races, previous-comments, agent-native, learnings-researcher.

Testing gaps: No end-to-end test asserts the multi-expression PromQL heatmap first-expression-only behavior through the buildHeatmapSeriesConfig path; config-type switching while on a Heatmap display type (the heatmapMode override and auto-submit ref change in EditTimeChartForm.tsx) is covered only by the unit/e2e happy path.

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

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds PromQL support to heatmap charts.

The PR appears safe to merge; no new actionable issue was found.

What we checked:

  • Heatmaps stay range-only: The range endpoint runs because Heatmap does not support instant queries. Only its first expression is queried.
  • Trace drilldowns stay separate: The tile builds a trace-search URL only for builder charts in distribution mode. PromQL heatmaps cannot reach that action.

Summary

Adds PromQL heatmaps with one row per returned series.

  • Supports the editor preview and saved dashboard tiles.
  • Uses range queries, heatmap granularity, variables, macros, and legend templates.
  • Adds unit tests and an end-to-end save-and-reload test.
  • The earlier missing-argument and stacked-line issues are fixed. The file-size thread was manually resolved by pulpdrew without explanation.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[PromQL heatmap config] --> B[Force series mode]
  B --> C[Resolve heatmap granularity]
  C --> D[Query first expression over time]
  D --> E[Build one row per series]
  E --> F[Render preview or dashboard tile]
Loading

Reviews (8) · Last reviewed commit: "Merge branch 'main' into drew/heatmap-pr..." · Reviewed by Greptile

teeohhem
teeohhem previously approved these changes Oct 7, 2026

@teeohhem teeohhem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a merge conflict left

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 8
  • Production lines changed: 149 (+ 282 in test files, excluded from tier calculation)
  • Branch: drew/heatmap-promql-series
  • Author: pulpdrew

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 127 in total (1.77%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 405 passed • 1 skipped • 1322s

Status Count
✅ Passed 405
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit eeabaeb into main Oct 7, 2026
43 of 44 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/heatmap-promql-series branch October 7, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants