Adding units to histogram

Grafana v11.2.0

How to add units to histogram bucket upper limits of a Prometheus histogram with log2 bucket organization?

log2 buckets histogram using bar gauge

(bar gauge; query data source option format:heatmap)

I want to display a Prometheus-originating histogram, which has its buckets organized with log2 limits, such as (1…2], (2…4], and so on. When test-driving this early with users, the immediate response was almost unisono: “what do the bar X labels mean?” (please see mockup screenshot above).

The bar gauge’s query options use {{le}} for determining the bucket X marks. I would like to show ≤123µs instead of just 123. How can I achieve this, or is this not supported?

Hi,

I think you could achieve that by going to Standard Options => Display Name and typing in there <= ${__field.labels.le} µs (where le is the name of the label). You could do the same by using Organize Fields by Name transformation, though I find Display Name better for that case.

1 Like

This works, thank you very much! Am I correct that while there is variable substitution, there is no general expression evaluation to, say, use 1k instead of 1024, et cetera?

I don’t think there is (which doesn’t mean there is not :sweat_smile:). If your buckets won’t change, I think you could utilize Organize Fields Transformation and rename 1024 to <= 1k. Or you could try mixing both! The ${__field.labels.le} expression I found in data links section (when you go into data links section and type $, a list of all possible variables will be displayed - not all of them works in Display Name though).