Group multiple variables into a single selection

I’m trying to build a Grafana dashboards with panels based on multiple different datasources (AWS CloudWatch, Elasticsearch, etc.) which allows the selection of the environment (dev, stage, prod) and changes all datasources accordingly.

We could name our datasources based on a pattern (e.g. aws-<env>) and use the value of a custom variable to filter those datasources. However, especially with Cloudwatch, we often have to filter the metrics based on AutoScalingGroupName which is auto-generated and thus cannot be filtered this way.

So i’m basically looking for way to group variables like

  • dev:
    • aws_datasource = aws-dev
    • elk_datasource = es-dev
    • foo_app_asg_name = my-autoscalinggroup-123
  • stage:

Maybe I could dump these values into a Postgres database and use a custom query to select these values but the would split up the configuration of the dashboards which i would like to avoid.

2 Likes