Skip to content

Support limiting histograms bucket count #111

@Haleygo

Description

@Haleygo

As described in this blog, VictoriaMetrics histograms do not require pre-defining bucket ranges or bucket numbers; instead, buckets are created dynamically as needed.

However, from the code, the bucketsCount is hardcoded asdecimalBucketsCount * bucketsPerDecimal=27 * 18 = 486
https://github.com/VictoriaMetrics/metrics/blob/58ce9991981bd6363af8c6f5a2c907f4e4f554fc/histogram.go#L11-17

But there are cases where users do not require such high granularity in histograms. For example, the metric vm_http_request_duration_seconds{path="/metrics"} is present on all VictoriaMetrics servers, but users may not need high granular buckets like vmrange="1.668e-05...1.896e-05", vmrange="1.292e-05...1.468e-05". Having these small granularity buckets increases the number of exposed series unnecessarily.

Image

https://play.victoriametrics.com/select/0/prometheus/graph/#/?g0.range_input=15m&g0.end_input=2026-01-09T09%3A23%3A02&g0.relative_time=last_15_minutes&g0.tab=0&g0.tenantID=0&g0.expr=sort_by_label_numeric%28vm_http_request_duration_seconds_bucket%7Binstance%3D%2210.71.7.252%3A8427%22%2Cjob%3D%22vtclusterlb-play%22%7D%2C+%22vmrange%22%29&g0.step_input=1s&display_mode=lines&legend_hide_duplicates=true

Describe the solution you'd like

It would be great to support limiting the bucket count when creating a histogram by configuring parameters such as MaxBucketNumber, and the bucket range can dynamically adapt to the new value;
Or support changing buckets resolution by adjusting bucketsPerDecimal.

However, since the bucket configuration is no long static, users cannot perform histogram calculations across different time series if any of them has customized bucket option settings.

Additional information:

Prometheus native histograms supports changing NativeHistogramBucketFactor or limiting the bucket count, see https://prometheus.io/docs/specs/native_histograms/#limiting-the-bucket-count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions