Concatenating dashboard variables

Hi all,

My apologies if this was already discussed (pretty sure it was) but i can’t find it (my searching skills are legendary in a horrible way)…

  • What Grafana version and what operating system are you using?
    Grafana 10.1.4 running on EKS

  • What are you trying to achieve?

Trying to concatenate multiple variables on a dashboard so it’s easier to manage sources.
I have multiple sources for each customer.

Customer deployment A

  • Prometheus
  • Cloudwatch
  • Logging

Customer deployment B

  • Prometheus
  • Cloudwatch
  • Logging

Customer deployment C

Customer deployment D

Right now, i am adding the variables to the dashboard, but each time i want to change, i need to go 1 by 1 and change them.

Variable 1 - Customer X Prometheus
Variable 2 - Customer X CloudWatch
Variable 3 - Customer X Logging

Is there a way to create a variable that would change all at once?

  • Customer var
    – Change Prometheus
    – Change CloudWatch
    – Change Logs

So, the dashboard still refers to the datasource choice, but those are all changed at once by a single var?

Thanks in advance,

Up :slight_smile:
Anyone has an idea on how to do this?

Still looking for a way to do this :frowning:

Anyone can weigh in on this? :slight_smile:

Ok, i was able to do it for anyone who is interested.

Step 1:
Define custom variable named “customer” with any label you want.

On this variable, the partial name of the datasources is defined as values separated by commas.
ie: CustomerA, CustomerB

Step 2:
Change the original queries with the following regex:


How does it work?

Let’s imagine 2 datasource names:


When you define datasources, you define them as:


With the above solution, this will give you a single dropdown, aggregating the datasources.

Then, it’s just a matter of hiding the original datasources from the dashboard display and done.
You only show 1 drop down for both datasources.