是否有一个简单的PromQL语句用于将累积直方图转换为有序直方图



众所周知,从prometheus获得的bucket度量是累积直方图。是否有一个简单的PromQL语句用于将累积直方图转换为有序直方图?

例如:

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

转换为:

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

非常感谢!

我不知道有这样的函数。对于哪个确切的用例,您需要它?

顺便说一句,在VictoriaMetrics中有一种直方图的替代实现,看起来它们的展示格式与您想要的很接近:

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

最新更新