'Match by exported instance in Grafana and Prometheus
I'm working in Grafana and Prometheus and I have Pushgateway exporting some stats for me. In Grafana, I am trying to display these results per machine. My jobs match an entire lab and the instance is related to the machine (ie. ab01:9100, ab02:9100 etc). I try to do '''avg(cpu_usage{exported_instance=~"$instance")''' but that doesn't work and I suspect it is because the exported_instance is ab01 and the instance is ab01:9100. Is there a way for me to match this? Do I need to use a re2 regex?
Solution 1:[1]
Use the following query:
avg(cpu_usage{exported_instance=~"${instance}.+")
Or something more specific, like:
avg(cpu_usage{exported_instance=~"${instance}:9100")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Marcelo Ãvila de Oliveira |