discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
538 stars 156 forks source link

Custom buckets for built-in metrics #289

Open smileart opened 1 year ago

smileart commented 1 year 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 1 year 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.