Skip to content

feat(promql): run PromQL on the metric tables - #2663

Open
Makisuo wants to merge 24 commits into
promql/1-enginefrom
promql/2-warehouse
Open

Makisuo wants to merge 24 commits into
promql/1-enginefrom
promql/2-warehouse

Merge branch 'promql/1-engine' into promql/2-warehouse

5c23298
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 16, 2026 in 3m 8s

Confidence 8/10 · No issues found

🟢 Confidence 8/10 · likely safe to merge. chDB tests pin the query layer against the reference, but no test drives PromqlQueryService's successful selector read end to end.
1 note · tests partial −1 · risk high −1 · 2/2 new units observable

Runs PromQL against the metric tables: metric_catalog resolves a selector's name to stored metrics, each (table, component) becomes one warehouse query with label matchers pushed into WHERE, and the rows become series and buckets for the evaluator. Org-scoped throughout and pinned by chDB tests.

  • promqlSelectorQuery resolves stored names and pushes label matchers into WHERE
  • seriesLabels/labelValueExpr build Prometheus labels in TypeScript and ClickHouse alike
  • PromqlQueryService validates, plans, reads the catalog once, runs selectors four-at-a-time
  • Histograms expand into cumulative le series; delta sums accumulate into counters

Still open from earlier reviews

Production impact

Telemetry this change adds and removes (3)
  • ➕ span name PromqlQueryService.readCatalog · packages/backend/src/services/promql/PromqlQueryService.ts:100
  • ➕ span name PromqlQueryService.readSelector · packages/backend/src/services/promql/PromqlQueryService.ts:122
  • ➕ span name PromqlQueryService.query · packages/backend/src/services/promql/PromqlQueryService.ts:163
What was checked
  • Every selector and catalog query filters OrgId (ch/queries/promql.ts:123, :366)
  • All four metric tables carry the columns the scan reads (Flags, Value, Count, ExplicitBounds)
  • planRequests already extends the scan start by the selector window (engine/plan.ts:91)
Observability coverage: 2 of 2 changes observable
Change Kind Observable Evidence
PromqlQueryService.query / readSelector service yes Effect.fn named spans plus maple.promql.* attributes; selector queries run through compiledQuery({ context: "promqlSelector" })
catalog read from metric_catalog warehouse query yes compiledQuery(..., { profile: "discovery", context: "promqlCatalog" })

5c23298 · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.