How to create Histogram metrics?

1,938 views
Skip to first unread message

bruno....@gmail.com

unread,
Nov 25, 2016, 9:19:13 AM11/25/16
to Prometheus Users
Hi all,

I started using Prometheus a couple of ago to monitor a few set of server used for experimental work (hence a newbie in the community).
NodeExporter provides a great amount of metrics for that but from what I have seen none of these are Histogram.

As a simple example I would like to collect data on the amount of incidents where the cpu/ram/disk utilization is above a certain threshold.
I'm not sure if recording rules are supposed to be used to create these metrics as there is already a specific metric type for Histogram.

I would like to know if there is any example which I could base on for my use case. 
Also, what would be the best practice to implement this - is recording rules a good approach?

Best regards,
Bruno.

Julius Volz

unread,
Nov 25, 2016, 8:14:08 PM11/25/16
to bruno....@gmail.com, Prometheus Users
Hi there,

Usually you would create one of the client libraries (the one for your language) to create a histogram. For an example in Go, click the "Example" text under https://godoc.org/github.com/prometheus/client_golang/prometheus#Histogram.

Or see for example this histogram in a demo service: https://github.com/juliusv/prometheus_demo_service/blob/master/api.go#L16-L25

When it gets exposed over HTTP, it's simply one time series per less-than-or-equals ("le") bucket. If you have a single concrete acceptable threshold, then you maybe only need one bucket below and one bucket above the threshold to see how many requests are below/above the threshold. See also Apdex score calculation with Prometheus: https://prometheus.io/docs/practices/histograms/#apdex-score

If you want to see a concrete example of how a histogram looks in the text format, see the text format specification: https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details - but a client library will usually do this for you.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/a8386dfd-91a3-4529-9b14-c5c9cee8aafd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julius Volz

unread,
Nov 25, 2016, 8:14:58 PM11/25/16
to bruno....@gmail.com, Prometheus Users
On Fri, Nov 25, 2016 at 6:14 PM, Julius Volz <juliu...@gmail.com> wrote:
Usually you would create one of the client libraries (the one for your 

s/you would create/you would use/ 

Bruno Grazioli

unread,
Nov 28, 2016, 3:54:23 AM11/28/16
to Prometheus Users, bruno....@gmail.com
Hi Julius,

The example in the demo service is exactly what I was looking for!
Thanks for the help.

BR,
Bruno.
Reply all
Reply to author
Forward
0 new messages