I'm using grafana and prometheus to query several metrics from different environments and instances/clusters. Regex helps me to reduce number of queries in the grafana dashboard.
For example, instead of creating a query for each instance (sometimes I can not know instances names or quantity), I'm using this:
{__name__=~"ReadUser:.*",account="dev",Function="Max"}
This way I'm getting metrics from several different dynamically created instances regarding the operation of reading a user.
Of course, I can not use it on a query like this:
increase(ReadUser:<instance-name>{account="dev",Function="TotalDuration"}[30s]) / ignoring(Function) increase(ReadUser:<instance-name>{account="dev",Function="Counter"}[30s])
My question is how can I use regex in order to use only one promql query to show this query result for all available instances (remember they are dynamically created and can get to a pretty large number)
To put it plain and simple: Do not put stuff like the instance name into a metric name /
__name__
. If you cannot change it in the source, rewrite the labels with metric relabel config.