promql: fix smoothed interpolation across counter resets#17988
Merged
roidelapluie merged 1 commit intoprometheus:mainfrom Feb 2, 2026
Merged
promql: fix smoothed interpolation across counter resets#17988roidelapluie merged 1 commit intoprometheus:mainfrom
roidelapluie merged 1 commit intoprometheus:mainfrom
Conversation
Fix incorrect interpolation when counter resets occur in smoothed range selector evaluation. Previously, the asymmetric handling of counter resets (y1=0 on left edge, y2+=y1 on right edge) produced wrong values. Now uniformly set y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset. This fixes rate calculations across counter resets. For example, rate(metric[10s] smoothed) where metric goes from 100 to 10 (a reset) now correctly computes 0.666... by treating the counter as resetting to 0 rather than producing inflated values from the old behavior. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
krajorama
approved these changes
Feb 2, 2026
Member
krajorama
left a comment
There was a problem hiding this comment.
LGTM. Seems obvious in hindsight.
roidelapluie
added a commit
to grafana/mimir
that referenced
this pull request
Feb 5, 2026
The upstream Prometheus change (prometheus/prometheus#17988) fixed incorrect interpolation when counter resets occur in smoothed range selector evaluation. The old behavior asymmetrically handled counter resets (y1=0 on left edge, y2+=y1 on right edge) which produced wrong values. The fix uniformly sets y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset. This updates our interpolate function to match the new behavior by removing the leftEdge parameter and adjusting test expectations accordingly. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
roidelapluie
added a commit
to grafana/mimir
that referenced
this pull request
Feb 5, 2026
The upstream Prometheus change (prometheus/prometheus#17988) fixed incorrect interpolation when counter resets occur in smoothed range selector evaluation. The old behavior asymmetrically handled counter resets (y1=0 on left edge, y2+=y1 on right edge) which produced wrong values. The fix uniformly sets y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset. This updates our interpolate function to match the new behavior by removing the leftEdge parameter and adjusting test expectations accordingly. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
roidelapluie
added a commit
to grafana/mimir
that referenced
this pull request
Feb 5, 2026
The upstream Prometheus change (prometheus/prometheus#17988) fixed incorrect interpolation when counter resets occur in smoothed range selector evaluation. The old behavior asymmetrically handled counter resets (y1=0 on left edge, y2+=y1 on right edge) which produced wrong values. The fix uniformly sets y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset. This updates our interpolate function to match the new behavior by removing the leftEdge parameter and adjusting test expectations accordingly. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
roidelapluie
added a commit
to grafana/mimir
that referenced
this pull request
Feb 5, 2026
The upstream Prometheus change (prometheus/prometheus#17988) fixed incorrect interpolation when counter resets occur in smoothed range selector evaluation. The old behavior asymmetrically handled counter resets (y1=0 on left edge, y2+=y1 on right edge) which produced wrong values. The fix uniformly sets y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset. This updates our interpolate function to match the new behavior by removing the leftEdge parameter and adjusting test expectations accordingly. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
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.
Fix incorrect interpolation when counter resets occur in smoothed range selector evaluation. Previously, the asymmetric handling of counter resets (y1=0 on left edge, y2+=y1 on right edge) produced wrong values.
Now uniformly set y1=0 when a counter reset is detected, correctly modeling the counter as starting from 0 post-reset.
This fixes rate calculations across counter resets. For example, rate(metric[10s] smoothed) where metric goes from 100 to 10 (a reset) now correctly computes 0.666... by treating the counter as resetting to 0 rather than producing inflated values from the old behavior.
Which issue(s) does the PR fix:
Does this PR introduce a user-facing change?