Replies: 13 comments 2 replies
-
I have the same question. @brian-brazil is this how we are expected to build a Histogram in a custom collector? |
Beta Was this translation helpful? Give feedback.
-
Experimenting with this a bit, I was able to write a custom collector that utilizes the regular
Example:
In your project's initialization code, ensure that the custom collector is registered. I'm certain this is not supported, but implementing the Histogram's logic on my own sounds dreadful. |
Beta Was this translation helpful? Give feedback.
-
That's how I'd do it, keep in mind that you possibly want to switch the type to GaugeHistogram before sending it on if you're using a custom collector like this. |
Beta Was this translation helpful? Give feedback.
-
Nice, glad I am on the right track. What is the benefit of using the |
Beta Was this translation helpful? Give feedback.
-
It's a type thing, so may be used by downstream tooling for better hints etc.. If the data is based on counters then it's a Histogram. If it's a snapshot of current state it's a GaugeHistogram. |
Beta Was this translation helpful? Give feedback.
-
Interesting, I've never seen a Appreciate the help! |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
You should create a new Histogram for each collect, otherwise you're risking race conditions. |
Beta Was this translation helpful? Give feedback.
-
Ah yes, my mistake. It's the job of Prometheus to collect the scrapes and store them within the Histogram. :) |
Beta Was this translation helpful? Give feedback.
-
Well.. actually, am I correct about that? For example, I have a How do I ensure that this |
Beta Was this translation helpful? Give feedback.
-
In that case, I guess you’re not proxying the data anymore? My use case is
for reading counters from another system/format and exposing those as
Prometheus metrics.
…On Wed, 1 Sep 2021 at 20:54, Matthew Bobke ***@***.***> wrote:
Well.. actually, am I correct about that? For example, I have a Counter
that is tracking the number of times a specific operation is performed.
That counter is instrumenting this exporter that I'm writing, and therefore
is not recreated on each scrape.
How do I ensure that a Histogram exposes buckets that are potentially
incrementing on each /metrics call with new data from the external API?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#683 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHDBWJZHJRVNDO2WAGMPGNTT72AHXANCNFSM5APUTDWQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
In that case, manually putting together the Histogram's samples is what I'd do. |
Beta Was this translation helpful? Give feedback.
-
We (the Prometheus team) are trying out Github discussions so I moved this as it is not an issue with the library. Thanks all for the great answers. |
Beta Was this translation helpful? Give feedback.
-
When using a histogram metrics we can use the 'observe' method to evaluate which bucket our latest sample will fall in:
E.g.
h1.labels('device-1').observe(value.get('latest_sample'))
->
However as I am proxying metrics I believe I should be using a Customer Collector and the
HistogramMetricFamily
which only providesadd_metric
which seems to just populate all the buckets.am I supposed to calculate the buckets in my code before writing the metric?
Beta Was this translation helpful? Give feedback.
All reactions