On 27.08.21 03:55, José San Gil wrote:
> 
> We're recording the duration of completed operations within our system. 
> Every time something succeeds, we observe the duration using a Prometheus 
> histogram.
> 
> - I set up the buckets using an exponential distribution: 1000, 5000, 
> 25000, 125000, 625000.
> - Each observation includes around 6 labels e.g: operationType, 
> organizationId
> 
> I want to count the number of observations per bucket for a specific 
> operation type within a given range. I tried the following queries (using a 
> Grafana Bar Gauge with Heatmap format):
> 
> sum(operation_x_bucket{operationType="TypeA"}) by (le)
> 
> 
> I also tried using the `increase` function, but I'm clearly missing the 
> point here (I also tried with a fixed range vector).
> 
> sum(increase(operation_x_bucket{operationType="TypeA"}[$__range])) by (le)
> 
> The result in both case doesn't make sense. *The values are way below the 
> real number of successful operations*.
> 
> I validated that operations are properly observed, so my guess is that I'm 
> completely misunderstanding Prometheus _bucket usage. 
> 
> *What's the proper way to count many observation per bucket do we have for 
> given label value?*

Perhaps you are confused by the fact that the buckets are cumulative?
That means that the bucket marked by {le="25000"} contains all
observations of 25000 or below (not just those between 5000 and 25000).

If you want to get, let's say, the observations between 5000 and 25000
in the last 10m, you need something like

    increase(operation_x_bucket{operationType="TypeA",le="25000"}[10m])
    - increase(operation_x_bucket{operationType="TypeA",le="5000"}[10m])
    
-- 
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/20210830204942.GK1307%40jahnn.

Reply via email to