Skip to content

fix non counter warning on series without metric name#12922

Closed
yeya24 wants to merge 1 commit intoprometheus:mainfrom
yeya24:fix-warning-non-counter
Closed

fix non counter warning on series without metric name#12922
yeya24 wants to merge 1 commit intoprometheus:mainfrom
yeya24:fix-warning-non-counter

Conversation

@yeya24
Copy link
Copy Markdown
Contributor

@yeya24 yeya24 commented Oct 2, 2023

When I run a nested subquery like this rate(sum by (series) http_requests_total[5m:1m]), I got a warning of possible non counter.

It looks like the check doesn't consider the case where metric name label is aggregated away.

Signed-off-by: Ben Ye <benye@amazon.com>
@yeya24
Copy link
Copy Markdown
Contributor Author

yeya24 commented Oct 10, 2023

Umm, maybe @beorn7 or @zenador can help take a look?

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Oct 11, 2023

I agree that we should not issue the info-level warning for an unnamed metric, mostly because it is possible to write a query where an unnamed metric can still be seen as a counter.

However, in your case, i.e. rate(sum by (series) http_requests_total[5m:1m]), I would recommend to write the expression as sum by (series) (rate(http_requests_total[5m:1m])) to make sure counter resets are treated properly. ("First the rate, then aggregate.") In fact, in most cases, I would assume an unnamed metric should not be considered a counter anymore. But as said, because there are cases where that's fine, we should not issue the warning.

Note that there is already #12945 for another case where we issue this info-level warning falsely.

@yeya24
Copy link
Copy Markdown
Contributor Author

yeya24 commented Oct 11, 2023

However, in your case, i.e. rate(sum by (series) http_requests_total[5m:1m]), I would recommend to write the expression as sum by (series) (rate(http_requests_total[5m:1m])) to make sure counter resets are treated properly.

Thanks for the reply. I agree with you. The query might not be a good example. Just want to show that this warning might be wrong for those unamed metrics.

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Oct 14, 2023

Yes, definitely. We should not create the annotation if rate is applied to an unnamed metric.

@beorn7
Copy link
Copy Markdown
Member

beorn7 commented Oct 17, 2023

So we had a bunch of people submitting fixes for this. A fix for the issue addressed by this PR has already been merged (without tracking who submitted what first, please don't be mad at me because of that). Therefore, I'll close this. Thanks for your contribution anyway.

@beorn7 beorn7 closed this Oct 17, 2023
@yeya24 yeya24 deleted the fix-warning-non-counter branch October 17, 2023 17:15
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.

2 participants