Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max_over_time treats NaN as the max #4385

Closed
jacksontj opened this Issue Jul 14, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@jacksontj
Copy link
Contributor

jacksontj commented Jul 14, 2018

Bug Report

What did you do?
a simple query like max_over_time(foo[30m])

What did you expect to see?
I expected to see the largest value

What did you see instead? Under which circumstances?
If there was a single NaN in the time range then the value returned is NaN. I made an example test case (which fails) to showcase the issue: jacksontj@a36f351

Environment

  • Prometheus version:

    verified on 2.2, 2.3, and master

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 14, 2018

Thanks for the report. We must have not fixed this for min/max while we were doing the others.

@jacksontj

This comment has been minimized.

Copy link
Contributor Author

jacksontj commented Jul 14, 2018

I can submit a PR with the test+fix. What is the desired behavior? Should NaNs be treated as the smallest thing? Or excluded from comparison? Personally seems like they should be excluded, but either way works for me.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 14, 2018

We should do the same as max does, and only return a NaN if there's only NaNs.

@jacksontj

This comment has been minimized.

Copy link
Contributor Author

jacksontj commented Jul 14, 2018

#4386 with the fix and some tests. I noticed that clamp_min and clamp_max still use the math.Max/Min functions, so presumably have similar issues.

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Jul 16, 2018

@jacksontj It's not clear to me what the right behavior of clamp_{min,max} would be in the face of NaNs, whether it should simply preserve NaNs or take the clamp value. Probably the current behavior is ok?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 16, 2018

I'm not sure what the right behaviour is there either, I'd say we wait until a use case comes up.

jacksontj added a commit to jacksontj/prometheus that referenced this issue Sep 25, 2018

Change max/min over_time to handle NaNs properly
We only want to return a NaN if the NaN is the only value

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>

Fixes prometheus#4385

brian-brazil added a commit that referenced this issue Sep 26, 2018

Change max/min over_time to handle NaNs properly (#4386)
We only want to return a NaN if the NaN is the only value

Signed-off-by: Thomas Jackson <jacksontj.89@gmail.com>

Fixes #4385
@lock

This comment has been minimized.

Copy link

lock bot commented Mar 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 25, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.