-
Notifications
You must be signed in to change notification settings - Fork 848
Open
Description
Bug Description
When querier.align-querier-with-step: true is configured, the query_range API returns data points outside the user's requested time window.
Steps to Reproduce
- Configure Cortex with:
querier: align_queries_with_step: true split_queries_by_interval: 1h
- Send a
query_rangerequest:start=2024-01-01T09:01:00Z end=2024-01-01T10:00:00Z step=10m - Observe the response contains a sample at
09:00:00— outside the requested range.
Expected Behaviour
Response contains only samples within [start, end] as requested.
Actual Behaviour
Response contains samples starting from 09:00:00 (floored to nearest step) instead of 09:01:00.
Root Cause
StepAlignMiddleware mutates the request before the results cache and downstream querier:
start = floor(start / step) * step // 09:01 → 09:00
Once this mutation happens, the original start is permanently lost — no downstream middleware can trim the response back to the user's requested range.
Proposed Fix
See PR: #7288
A new opt-in RangeTrimMiddleware controlled by querier.trim-response-to-requested-range (default: false) that clips the final response to the original [start, end].
Environment
- Cortex version: latest master
- Affected config:
querier.align-querier-with-step: true
Reactions are currently unavailable