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

Grafana + Prometheus how to use regex in query metrics?

我们正在动态添加新指标。是否可以在 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}"}

您可以替换:

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

收件人:

sum(application_test_total{color=~"[0-9]{1}"})