Leo
Leo

Reputation: 2103

borderless prometheus buckets

to have a working prometheus histogram i need a bucket which is a set of values that when passed to observe method(i use https://github.com/prometheus/client_ruby) will be recorded. so when my bucket is :

[1,2,3, 100] 

its going to record 1 as 1, 2.1 as 2 etc.

how can i make it record everything between 3 and 100 without explicitly passing values to the bucket? how can i make it record values from 1 to infinity like here https://hexdocs.pm/prometheus_ex/Prometheus.Buckets.html ?

Upvotes: 0

Views: 1378

Answers (1)

yamenk
yamenk

Reputation: 51906

A histogram is represented as a set of counters where each counter represents a bucket. It is typically used to track latency.

Each bucket stores a number representing events less than the bucket value.

hello_world_latency_seconds_bucket{le="1.0",} 16.0
hello_world_latency_seconds_bucket{le="2.0",} 16.0
hello_world_latency_seconds_bucket{le="3.0",} 16.0
hello_world_latency_seconds_bucket{le="100.0",} 16.0
hello_world_latency_seconds_bucket{le="+Inf",} 16.0 

The le label come from the array passed to the histogram upon initilization.

how can i make it record everything between 3 and 100 without explicitly passing values to the bucket?

You need to pass the specific values of 3 and 100 explicitly. Moreover, you can't directly get everything between 3 and 100, you need to subtract the following to get this number.

hello_world_latency_seconds_bucket{le="100.0",} - hello_world_latency_seconds_bucket{le="3.0",}

How can i make it record values from 1 to infinity

Same technique as above:

hello_world_latency_seconds_bucket{le="+Inf",} - hello_world_latency_seconds_bucket{le="1.0",}

Upvotes: 4

Related Questions