0

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 ...) )

1
  • 1
    If you know which services in which groups - you can just create a custom variable with label for group name, and value for regex with services. If you don't you'll first need to put that grouping relation somewhere, and then create variables based on where its stored. Commented May 23 at 22:36

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer. But what about each key having static list of services ? Not regular expression
@voipp how is a "static list of services" different from database-service|backup-service|service-1|service-2? What do want to do that you can't do with a list of alternatives such as a|b|c?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.