discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
525 stars 153 forks source link

Custom buckets for built-in metrics #289

Open smileart opened 11 months ago

smileart commented 11 months ago

In the documentation I see a section about custom histogram buckets. In attempt to change the default buckets for the built-in metrics in --historgram mode, I've added the following to my initializers/prometheus_exporter.rb

PrometheusExporter::Metric::Histogram.default_buckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5.0, 10.0, 20.0, 30.0, 60.0]

But apparently the default buckets max size is still 10.0. Am I doing it wrong?

Thank you in advance!

smileart commented 10 months ago

As a workaround, I've created a new empty collector file, passed it with the --collector option to the prometheus_exporter binary just to hook into its scope and added the line from above ⬆️. It seems to help, but I suspect there must be a better/official way. 🤔 Just wanted to leave this here in case somebody would be looking for a workaround too.