Repository navigation
fix(data_plane): read query times as RFC 3339 too, as the Prometheus API does - #868
Merged
Merged
Conversation
…API does time, start and end were read only as Unix seconds; anything else, such as the RFC 3339 times vmalert sends, was forwarded instead of answered from the plan. They are now parsed as Prometheus parses them (Unix seconds with an optional fraction, or RFC 3339 with optional fractional seconds and a zone offset), and a time in neither form gets Prometheus' 400.
An empty time is now; Prometheus' min and max times are forwarded; Go's lenient RFC 3339 forms are accepted; a numeric fraction is rounded on its own, as Prometheus rounds it; one BadParameter error type.
zzylol
force-pushed
the
fix/prometheus-time-params
branch
from
November 24, 2026 15:04
d19ea6b to
28cdc8f
Compare
zzylol
marked this pull request as ready for review
November 24, 2026 15:05
zzylol
added a commit
that referenced
this pull request
Nov 24, 2026
…, label columns, RFC 3339 times, format 4 (#871) Ports #865, #869, #868 and #866 from the tiered-view-storage branch to main: a read-back view window is charged its own bytes; label text columns are rebuilt from the series identity; query times are read as Unix seconds or RFC 3339; view fragments are compact and zstd-compressed (view file format 4; formats 2 and 3 are set aside at startup). Tests adapted to main's APIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/v1/queryand/api/v1/query_rangefrom its plan only whentime,startandendwere Unix seconds. RFC 3339 times, which the Prometheus HTTP API allows and vmalert sends (for exampletime=2026-11-24T05:00:00Z), were forwarded to the fallback instead.time,startandendare parsed the way Prometheus'parseTimedoes:Zor±hh:mmoffset.invalid parameter "time": cannot parse "x" to a valid timestamp.Review guide
feat/tiered-view-storage, the demo branch.parse_time_msandrfc3339_msindata_plane/src/prometheus.rs, then the twoparsefunctions that call them.BadTimeandBadRangebecome oneBadParameter;no_forwardmessages inlib.rsnow also name Prometheus' min and max times.Behavior: before → after
The query
sum(sum_over_time(data[1m]))is planned every 10 s overdata./api/v1/query?time=120/api/v1/query?time=1970-01-01T00:02:00Z--no-forward: 422 "no query parameter")time=120time=1970-01-01T01:02:00+01:00,.000000000Z,-00:30offsets/api/v1/query_range?start=1970-01-01T00:02:30Z&end=180&step=10start=150time=yesterday,1970-13-01T00:00:00Z, no zone, space instead ofTbad_data,invalid parameter "time": cannot parse "yesterday" to a valid timestamptime=(empty)This serves the 4-system demo: the rule evaluator's queries are answered by the data plane, not the fallback.
Interfaces
data_plane/src/prometheus.rsThe two error types were merged because both had become identical string wrappers.
Usage: a rule evaluator sends
GET /api/v1/query?query=sum(sum_over_time(data[1m]))&time=2026-11-24T05:00:00Z.InstantQuery::parse→parse_time_ms("time", ..)givesSome(1_795_496_400_000). The engine evaluates the plan at that time, and the response carriesx-asap-execution: plan.Algorithm changes
Query time parsing.
text.parse::<f64>(), otherwise forward.Prometheus' min/max time strings are forwarded.
A float is taken as seconds: whole seconds plus the fraction rounded to the millisecond, as Prometheus'
Modf+Round.Otherwise
rfc3339_msreads the form Go'stime.Parse(time.RFC3339Nano, ..)accepts:T, a one- or two-digit hour;./,fraction of any length, truncated to the millisecond as Prometheus truncates a parsed time;Zor an offset of at most 24 h / 60 min;Days since the epoch come from Hinnant's civil-date algorithm.
Otherwise 400, with Prometheus' text.
parses_rfc3339_times: epoch-ms constants were computed independently, and it covers Go's lenient forms and rejected forms.time_params.rs: answers match across forms.{:?}vs Go%q);ParseFloataccepts.Decisions and open questions
Verification
cargo test -p data_plane --test time_params--no-forward)cargo test -p data_plane --lib prometheus::parses_rfc3339_timesnew; two expectations updated (RFC 3339 now parsed)server,range_queriescargo fmt --check,cargo clippy -p data_plane --all-targets -D warningsNew tests:
rfc3339_times_are_answered_from_the_plan_like_unix_seconds: instant and range queries in RFC 3339 forms are answered from the plan with the same body as the Unix-seconds form.times_in_neither_form_are_refused_as_prometheus_refuses_them: 400 with Prometheus' text fortime,startandend.prometheus_min_and_max_times_are_not_answered_from_the_plan: the two special strings are not refused as unparsable.Follow-ups
feat/tiered-view-storagehas landed on main (feat(data_plane): tiered view storage, push precompute by default, faster Remote Write decode #864). This fix should be re-targeted to main afterwards, as a cherry-pick of the squash commit; it touches onlyprometheus.rsandlib.rs.