0
votes

As we known, the bucket metrics got from prometheus are cumulative histogram. Is there a simple PromQL statement used convert cumulative histogram into ordinal histogram?

For example:

http_access_bucket{node="aaa",le="5"} 20
http_access_bucket{node="aaa",le="10"} 30
http_access_bucket{node="aaa",le="20"} 35
http_access_bucket{node="aaa",le="50"} 38
http_access_bucket{node="aaa",le="100"} 40
http_access_bucket{node="aaa",le="+Inf"} 40

convert to:

temp_bucket{node="aaa",le="5"} 20
temp_bucket{node="aaa",le="10"} 10
temp_bucket{node="aaa",le="20"} 5
temp_bucket{node="aaa",le="50"} 3
temp_bucket{node="aaa",le="100"} 2
temp_bucket{node="aaa",le="+Inf"} 0

thank you very much!

1

1 Answers

0
votes

I am not aware of such a function. For which exact use case you need it?

Btw, there is an alternative implementation of histograms in VictoriaMetrics and looks like their exposition format is close to what you're looking for:

vm_http_request_duration_seconds_bucket{path="/metrics",vmrange="1.000e-05...1.136e-05"} 4
vm_http_request_duration_seconds_bucket{path="/metrics",vmrange="1.136e-05...1.292e-05"} 1
vm_http_request_duration_seconds_bucket{path="/metrics",vmrange="1.292e-05...1.468e-05"} 4
vm_http_request_duration_seconds_bucket{path="/metrics",vmrange="1.896e-04...2.154e-04"} 2
vm_http_request_duration_seconds_bucket{path="/metrics",vmrange="1.000e-03...1.136e-03"} 1
vm_http_request_duration_seconds_sum{path="/metrics"} 0.0019834780000000003
vm_http_request_duration_seconds_count{path="/metrics"} 19