-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
history_quantile returns NaN when computed from 0 values #6645
Comments
Not sure thought if it's a big issue, I obviously cannot interpret the data between builds in any way other than a null value. I guess I could fix my issue by changing the query to include the last value to fill the holes if it's possible. Currently if I set a gauge it doesn't display anything relevant even if I tell it to display the last non null value. NaN is technically not null so I guess having a null would at least help with that. |
This is the expected behaviour, as you'd get a NaN also if you tried to calculate the average as that'd be dividing by zero. |
Well okay then, I guessed it might have been related to a division by 0. Then may be it should be a bug in the grafana source to allow a different interpretation of NaN vs Null. Because NaN is technically non null but not something worth showing in some cases. That said, the quickest workaround I found was to use that query instead to compute an average.
It's not ideal but does look like something I can live with for now. |
That's average since process start, not the last run. If you've more questions the -users list is the best place. |
Yes, not ideal. I did ask the question on the user list. As long as the data is correctly scraped I can live with interpreting it correctly later. |
Bug Report
Tried to display histogram_quantile of a query:
It returns:
But:
Returns this:
It seems the issue could be related to this one:
#4264
Here's a screenshot of what it looks like:
What did you expect to see?
I did expect the values of histogram quantile to be
null
if that's what they are instead ofNaN
. As value didn't change over time during those time period, it would make sense to have a null value as there can't be a quantile measured if there is no change. It could be 0 but in reality as I'm not observing any value it shouldn't return 0. In my case, I'm measuring build time but builds can be once per day, twice per hours of may be 30 times per minutes. But if no builds happen during a time frame, the value doesn't magically goes down to 0. Still, grafana does interpret NaN as null. When checking in the values returned I can see Null and the mouse hover displaysNaN
.Data being scraped
From what I could see, when the value changes, the query does work as intended but as builds aren't generated periodically the data can be scrapped multiple times with the same value as the buckets are not changed between scrapes.
But as the
sum(rate())
call does return values of 0, it seems like the histogram_quantile is doing something weird because it doesn't seem to return any NaN value and as far as I know, prometheus didn't scrape any NaN value either.The client being used is the prometheus_client and the piece of code relevant to this is this:
https://github.com/llacroix/prometheus-swarm-discovery/blob/master/prometheus_sd/service.py#L412
And the metric is defined here:
https://github.com/llacroix/prometheus-swarm-discovery/blob/master/prometheus_sd/metrics.py#L31
The service is running in asyncio but I believe it's irrelevant. The timing is correctly computed and the metrics output uses the prometheus_client api.
Environment
The text was updated successfully, but these errors were encountered: