简体   繁体   English

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

[英]Grafana + Prometheus how to use regex in query metrics?

We are dynamically adding new metrics.我们正在动态添加新指标。 Is it possible to use regex in Grafana query metrics?是否可以在 Grafana 查询指标中使用正则表达式?

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

How to avoid this?如何避免这种情况?

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

Is it possible to replace with this?可以用这个代替吗?

application_test_total{color="[0-9]{2}"}

You can replace:您可以替换:

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

To:到:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM