Add test to demonstrate xincrease bug #629
Open
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.
We are testing xfunctions in our set up and here is one issue we hit when testing with super sparse metrics.
Here is the problem we got and I created a simple test to reproduce the problem and added to this PR.
xincrease(http_requests_total[1m]) > 0to have value at the steps when sparse metrics were ingested.xincreasevalue is 0 for the sample at t2 if my query start time is before 2025-09-07T07:48:38Z. If my query start time is equal to or after 2025-09-07T07:48:38Z,xincreaseshows the correct value.2025-09-07T07:48:38Zis kind of the magic timestamp because it is t1 + 60m + 1m + 1s, where 60m is the ext lookback delta and 1m is the select range inhttp_requests_total[1m].The issue in
extendedRateis in this line. If the query start time is within [t1, t1 + ext lookback delta + select range],metricAppearedTsfor the series is set to t1 according to this. Thenif stepTime-offset <= untilcondition will not meet when evaluating another sample at a later timestamp.Proposed fix for this issue:
For each step, when there is only 1 sample selected within the select range, it is expected for
xincreaseto always return the sample value. It shouldn't be impacted by the start time of the query and if there is any sample close enough.Current logic. Depends on first sample timestamp.
Proposed logic, this doesn't rely on first sample timestamp. Also when there is only one sample within the select range, return its value. When there are more than 1 sample but they have the same value, return 0.