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

deriv() returns non-zero values even though my data hasn’t changed #1647

Closed
stapelberg opened this Issue May 19, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@stapelberg
Copy link

stapelberg commented May 19, 2016

Originally I thought this is a regression, but I see no proof of that — as per syslog, I’ve been using prometheus, version 0.18.0 (branch: stable, revision: f12ebd6) since the 15th of May, and the issue only now started to appear.

I have an alerting rule which looks at changes in state, see https://github.com/robustirc/robustirc/blob/669a278acd264e1e94c7ad8e7a6217be54585488/contrib/prometheus/robustirc_prometheus.rules#L19 for details.

This rule is now firing, even though there weren’t any changes in state.

When having a closer look, it turns out that deriv() returns values that are very close to 0 (e.g. -0.000000000006047549185814796), but not 0.

I ran the following two commands to capture the data and reproduce the issue:

wget -qO- http://localhost:9090/api/v1/query_range\?query\=raft_isleader\{instance\=\"ridcully\"\}\&start\='2016-05-19T18:00:00Z'\&end\='2016-05-19T22:00:00Z'\&step\=15s > /tmp/values.txt
values.txt

wget -qO- http://localhost:9090/api/v1/query_range\?query\=deriv\(raft_isleader\{instance\=\"ridcully\"\}\[10m\]\)\&start\='2016-05-19T20:00:00Z'\&end\='2016-05-19T22:00:00Z'\&step\=15s > /tmp/deriv.txt
deriv.txt

I would have expected deriv() to return 0 in this specific case.

Am I holding it wrong or is this a bug? If the former, do you have any suggestions to improve my alerting rule?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented May 19, 2016

That sounds like floating point inaccuracy, not much we can do about it.

Have you considered using the changes function?

@stapelberg

This comment has been minimized.

Copy link
Author

stapelberg commented May 20, 2016

Ah, changes does return 0. Does changes not involve floating point operations, or why does it not suffer from the same inaccuracies as deriv?

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented May 20, 2016

On 20 May 2016 at 08:48, Michael Stapelberg notifications@github.com wrote:

Does changes not involve floating point operations, or why does it not suffer from the same inaccuracies as deriv?

Everything in Prometheus is floating point. changes, however, does
something really simple, while deriv does
https://en.wikipedia.org/wiki/Simple_linear_regression

There are way more chances of running into accuracy issues there.

Björn Rabenstein, Engineer
http://soundcloud.com/brabenstein

SoundCloud Ltd. | Rheinsberger Str. 76/77, 10115 Berlin, Germany
Managing Director: Alexander Ljung | Incorporated in England & Wales
with Company No. 6343600 | Local Branch Office | AG Charlottenburg |
HRB 110657B

@stapelberg

This comment has been minimized.

Copy link
Author

stapelberg commented May 20, 2016

Thanks for the explanation. I’m closing this issue as we found an alternative solution (changes) and can’t do much about floating point inaccuracies.

@stapelberg stapelberg closed this May 20, 2016

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 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 24, 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.