Grafana + Prometheus如何在查询指标中使用正则表达式?

问题描述 投票:0回答:1

我们正在动态添加新指标。是否可以在Grafana查询指标中使用正则表达式?

application_test_total{color="0"}
application_test_total{color="1"}
application_test_total{color="2"}

如何避免这种情况?

sum(application_test_total{color="0"})+sum(application_test_total{color="1"})

可以用这个替换吗?

application_test_total{color="[0-9]{2}"}
prometheus grafana metrics
1个回答
0
投票

您可以替换:

sum(application_test_total{color="0"})+sum(application_test_total{color="1"})

收件人:

sum(application_test_total{color=~"[0-9]{1}"})
© www.soinside.com 2019 - 2024. All rights reserved.