col*_*itz 3 grafana prometheus
我在 Prometheus 中有一个直方图,而在 Grafana 中,我试图将其中一个标签的计数分布图作为百分比随时间的变化。我目前正在尝试类似的东西
sum(rate(histogram_count{label1="value1"}[5m])) by (label2)
/
sum(rate(histogram_count{label1="value1"}[5m]))
Run Code Online (Sandbox Code Playgroud)
但它没有返回任何值。难道我做错了什么?我只想要 label2 的每个值的计数总和除以计数总和。
问题是两边的标签不匹配。您可以使用group_left来进行多对一匹配,并ignoring忽略不匹配的标签:
sum by (label2)(rate(histogram_count{label1="value1"}[5m]))
/ ignoring (label2) group_left
sum(rate(histogram_count{label1="value1"}[5m]))
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅https://www.robustperception.io/using-group_left-to-calculate-label-proportions
| 归档时间: |
|
| 查看次数: |
3047 次 |
| 最近记录: |