Skip to content

feat(query): warm-tier fallback for /api/v1/query_range - #267

Merged
zzylol merged 1 commit into
mainfrom
range-query-warm-tier-fallback
May 16, 2026
Merged

zzylol merged 1 commit into
mainfrom
range-query-warm-tier-fallback

Conversation

@zzylol

@zzylol zzylol commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the range-query gap I documented earlier in this session. Per user direction: count_over_time is warm-tier-answerable by sampling; topk_over_time isn't standard PromQL anyway and falls through to the cold tier (Thanos parse-error is acceptable).

Sibling of PR #253's instant-query trait-dispatch fallback.

What changed

  • New method ASAPQueryEngine::execute_range_promql_modern(query, start_ms, end_ms, step_ms) — mirrors the analyzer + reducer dispatch from QueryEngine::execute(&str), but returns Matrix per the /api/v1/query_range wire-format spec.
  • process_range_query_request in http.rs — tries the legacy handle_range_query_promql first (unchanged), and on None calls the new modern method. Modern errors fall through to format_unsupported_query_response (which the EngineRouter can route to a cold-tier fallback if configured).

Prometheus semantics

The spec says evaluate at each t = start, start+step, …, end. The warm tier returns samples at native window-close granularity instead — finer than the user's step when window_size < step (more data, not less). Step-precise evaluation is a future refinement; clients that need exact step timestamps can downsample, or route step-precise queries to the cold tier. The step_ms parameter is accepted for API compatibility but currently unused; documented inline.

Test plan

  • Test 10 (controller_plan_to_range_query_count_over_time_cms) ingests heap-less CMS DPs via the same setup as Test 7, then queries count_over_time(endpoint_request_freq[10s]) via /api/v1/query_range. Asserts status=success, resultType=matrix, non-empty series.
  • All 10 e2e tests pass
  • cargo test --workspace --lib — 1533 pass, 0 fail

🤖 Generated with Claude Code

Closes the range-query gap I documented in PR #260's session
follow-up. Per-user direction (2026-05-16): count_over_time is
warm-tier-answerable by sampling; topk_over_time isn't standard
PromQL anyway and falls through to the cold tier (Thanos parse-
error is acceptable).

Sibling of PR #253's instant-query trait-dispatch fallback. New
`ASAPQueryEngine::execute_range_promql_modern(query, start_ms,
end_ms, step_ms)` mirrors the analyzer + reducer dispatch from
the `QueryEngine::execute(&str)` trait surface but returns
Matrix per the `/api/v1/query_range` wire-format spec.

Wire-up: `process_range_query_request` in `http.rs` tries
`handle_range_query_promql` first (legacy path, unchanged), and
on `None` calls the new modern method. If the modern path also
errors, it falls through to `format_unsupported_query_response`
(which the EngineRouter can route to a cold-tier fallback).

Prometheus semantics note: the spec says evaluate at each
`t = start, start+step, …, end`. The warm tier returns samples
at native window-close granularity instead — finer than the
user's step when window_size < step (more data, not less).
Step-precise evaluation is a future refinement; clients that
need exact step timestamps can downsample, or route step-
precise queries to the cold tier.

Test 10 (`controller_plan_to_range_query_count_over_time_cms`)
ingests heap-less CMS DPs via the same setup as Test 7, then
queries `count_over_time(endpoint_request_freq[10s])` via
`/api/v1/query_range`. Asserts `status=success`,
`resultType=matrix`, non-empty series.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 6687bc0 into main May 16, 2026
@zzylol
zzylol deleted the range-query-warm-tier-fallback branch July 17, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant