I have got grafana dashboard with panel , outputting the following metric:
rate(http_requests_total{service=~"${$service}"}[5m])
where $service is a variable. One can select service from drop-down list in grafana dashboard. The variable is a query label from victoria metrics data source.
I want to add the new variable named group which is a list of services. When you drop-down this variable from dashboard you see only group name , not services making up this group.
And I want to change the metric to look like the following:
avg(rate(http_requests_total{service=~"$<Select all services making up the group you selected>"}[5m]))
How can I accomplish this ?
PS. I tried to add relabling in config, add label group. But i dont know how to apply conditions in metric_relabel_configs (condition might be looking like if(service in [...] then group = group1 ...) )
If your groups are static, you can define a variable of type Custom
and then specify key-value pairs as the available options. The key is the name you want to display in your dropdown and the value is a regular expression matching your services. For instance:
group1 : database|backup|proxy, group2 : service-(dev|test|prod), group3 : service-[123]+
Whitespace around the colon :
is important