question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to provide different buckets for Prometheus histogram?

See original GitHub issue

In Prometheus, default histogram is defined as:

private double[] buckets = new double[]{.005, .01, .025, .05, .075, .1, .25, .5, .75, 1, 2.5, 5, 7.5, 10};

It is used in org/http4s/metrics/prometheus/Prometheus.scala:157 to measure response times.

The default bucket has good steps at start, but at is quite useless at end with resolution of 2.5s.

It would be nice, if there would be a way to set own bucket list, but I didn’t find such. Maybe it would be good idea to use custom bucket list, like:

responseDuration = Histogram
  .build()
  .buckets(0.005, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4, 4.2, 4.4, 4.6, 4.8, 5, 5.2, 5.4, 5.6, 5.8, 6, 6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4, 8.6, 8.8, 9, 9.2, 9.4, 9.6, 9.8, 10)
  //...

It has more than 4x buckets and has a bit better resolution on “fast” end and much better one on “slow” end, resolution is closer to linear - this can be useful in cases, when generated response depends on slow backend system(s). It could be even useful to add 0.5 steps up to 20 seconds.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mr-gitcommented, Mar 26, 2019

Current http4s API doesn’t expose this ability and uses default bucket, which is quite shallow and wide… Options:

  • use the buckets as I mentioned in main
  • close this as “not an issue” and forget about it
  • complicate current API and expose ability to provide custom bucket list
0reactions
mr-gitcommented, Apr 15, 2019

0.20.x is sufficient. thanks for letting me know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Histograms and summaries - Prometheus.io
You can approximate the well-known Apdex score in a similar way. Configure a bucket with the target request duration as the upper bound...
Read more >
Fun with Histograms - Prometheus Basics - Bryce Fisher-Fleig
Each bucket time series will contain the count of observations that was less than or equal to its le value for a given...
Read more >
Prometheus Histograms. Run that past me again?
1. The buckets are cumulative ... In the above example, each bucket was exclusive of the values on either side. The values that...
Read more >
Histograms with Prometheus: A Tale of Woe - LinuxCzar
Prometheus implements histograms as cumulative histograms. This means the first bucket is a counter of observations less than or equal to ...
Read more >
Improving histogram usability for Prometheus and Grafana
The number of per-histogram buckets can rapidly grow as you could see from the previous chapter. Each histogram bucket is stored as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found