Skip to content

promql: Add warning for too many resets in rate().#16860

Draft
sujalshah-bit wants to merge 1 commit into
prometheus:mainfrom
sujalshah-bit:warning_too_many_resets
Draft

promql: Add warning for too many resets in rate().#16860
sujalshah-bit wants to merge 1 commit into
prometheus:mainfrom
sujalshah-bit:warning_too_many_resets

Conversation

@sujalshah-bit

Copy link
Copy Markdown
Contributor

fixes: #16618.

@sujalshah-bit sujalshah-bit force-pushed the warning_too_many_resets branch from a8c4df8 to 2e3d3d1 Compare July 11, 2025 00:53

@bboreham bboreham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it looks promising.

Could you add some tests? E.g. that the annotation does appear when you expect, and doesn't appear when it shouldn't.

Comment thread promql/functions.go Outdated
}

resetRatio := float64(resetCount) / float64(numSamplesMinusOne)
if resetRatio > 0.6 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least this should be a const, probably configurable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably configurable

the tricky part with a global configuration is that acceptable counter reset ratios might be metric specific?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that this is a ratio, please give an example of what you're thinking about.
Probably this discussion should be on the issue, which is where 0.6 is proposed.

@sujalshah-bit sujalshah-bit force-pushed the warning_too_many_resets branch from 2e3d3d1 to da059e2 Compare July 13, 2025 02:18
http_requests_total{job="api2"} 10 20 5 6 25

eval instant at 5m rate(http_requests_total{job="api"}[5m])
expect info

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the new expect syntax to assert the exact msg too, see ref

@NeerajGartia21 NeerajGartia21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bboreham, Do you think we should apply this reset check for histograms as well? Also, I think we should consider adding a similar annotation for the increase function when excessive resets are detected.


eval instant at 5m rate(http_requests_total{job="api2"}[5m])
expect no_info
{job="api2"} 0.1388888888888889

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the indentations here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, I am not seeing any extra indentation in file.
Screenshot 2025-08-06 at 6 05 39 PM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be due to your IDE settings. Check if your tab size is set to 4 or 8 spaces, and ensure you're using either tabs or spaces consistently. That should fix the indentation mismatch.

@sujalshah-bit sujalshah-bit force-pushed the warning_too_many_resets branch from da059e2 to c62d412 Compare August 6, 2025 12:30
fixes: prometheus#16618.
Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
@sujalshah-bit sujalshah-bit force-pushed the warning_too_many_resets branch from c62d412 to b993120 Compare August 6, 2025 12:49
@sujalshah-bit

Copy link
Copy Markdown
Contributor Author

If the user does not set the flag(--query.max-reset-ratio), the default value (0.6) is used.

@sujalshah-bit sujalshah-bit marked this pull request as draft August 6, 2025 19:00
@github-actions github-actions Bot added the stale label Oct 6, 2025
@krajorama

Copy link
Copy Markdown
Member

Hello from the bug scrub!

This PR seems to have become somewhat stale @sujalshah-bit are you going to return to this? Also please note the work on delta metrics will likely introduce changes to reset detection and new use-cases (e.g. #18344)

@github-actions github-actions Bot removed the stale label Mar 24, 2026
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.

PromQL: add an annotation (warning) for too many resets in a counter

5 participants