-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Missing count and sum in prometheus histogram metrics #41573
Comments
Thanks @henrikno for creating this. |
@shmsr can you take a look? |
I'll take a look. |
Hi @henrikno 👋🏽 Apologies for taking some time to reply as I was busy investigating a couple of other bugs. I do understand it is not working as expected for you but this is how it is. So when
*_sum and *_count are intentionally left out. I am not sure why this decision was taken ~5years ago to omit it out.
Also, see this logic here how Prometheus Histogram is converted to an ES histogram:
As have a value of 23 for all buckets and hence the rate is turning out to be 0; so it's because of the sample input that you provided. I'd recommend reading the full logic there and further discussion here: elastic/apm-agent-python#1165 (comment). So, this is the reason why counts gives you an array filled with 0s. Also, if you
But yes you miss out the transformation from Prometheus Histogram to ES Histogram here as I need to check if it is safe to add Also, about the docs example that you mentioned: https://www.elastic.co/docs/current/integrations/prometheus#histograms-and-types-1
If you notice I hope this explanation helps. |
I get that it was an "intentional" decision to not add it, but I think that was a mistake as it makes it very difficult or impossible to query it. beats/x-pack/metricbeat/module/prometheus/collector/data.go Lines 147 to 148 in 367d94e
There's an enhancement issue that considers adding it elastic/integrations#5042 In the docs for histogram https://prometheus.io/docs/practices/histograms/
So a histogram is also "counter", so it should behave similar to a counter, so we can query it with a rate, avg etc. |
Thanks Henrik for updating. As previously discussed on Slack (and sharing here for those who weren't part of that conversation): I reviewed the Slack thread asking for histogram changes and Andrew's proposal regarding histogram implementation enhancements filed more than a year ago. Since this is Andrew's proposal, it requires further discussion and it'd be great if he can also share his views on this. We need to evaluate this thoroughly while considering customers who are using the current histogram implementation. Making changes has implications, so this needs detailed discussion with the Prometheus package owners and members of ES/ Kibana. The current code works as intended according to the original design assumptions. While I agree with Henrik that improvements are needed, we should discuss this in detail within our team. |
This prometheus histogram metric:
Gets turned into this in ES:
We are using use_types and rate, 1. because it's the default in the elastic-agent integration, and 2. to be able to query them in Kibana.
https://www.elastic.co/docs/current/integrations/prometheus#histograms-and-types-1
However, the values don't look like the example, and what we expect.
The
_count
and_sum
is missing. I was hoping to query the rate of the count/sum.Sidenote, if the buckets are diffed, I expected it to be named .rate. I was confused why the values did not match what the prometheus endpoint waas reporting at all. This is what it does for counters. Also for counters it keeps the original, but I can see that that would increase the storage.
Another thing that looks funny is the empty values
{"values":[],"counts":[]}
. Looks like this is happening because we use TSDS, which is also the default in the prometheus integration.I tried to reproduce it with just metricbeat 8.15.3.
Put the example at the top in a file called
metrics
, then runpython3 -m http.server 9000
Set this in metricbeat.yml
With use_types: true, rate_counters: false, I get a bunch of zeroes:
With rate_counters: false I expected to get the exact same values that prometheus reports.
Also missing _sum and _count. If I disable use_types, I do see the values, but there's one document per bucket which is extremely difficult to query.
The text was updated successfully, but these errors were encountered: