Use template variable to select multiple datasources


I have a use case in which I have multiple datacenters (us and eu for example), each board may contain multiple ES indexes as datasources (appLogs, sysLogs and deployLogs for example).

My problem is that each datacenter has a specific datasource. So when selecting US datacenter for instance I have to some how switch multiple board datasources on a single board.

Is there a way to do it without multiplying the same bashboard by the number of datacenters. We have multiple (6) datacenters and managing this number of boards will be rough.

Eugene Krapivin

Create dashboard variables:

And use it in the query.

Hey, thanks for the quick response.
I know how to use datasources as template variables, my question is a little bit different:
say I have 2 environments I that I monitor: EU and US
I have a dashboard that takes data from 2 indexes *-appLogs and *-sysLogs.
Since each ES index in grafana is setup as a datasource - I have 2 datasources in the same dashboard.

My current setup is using ES tribes in which case all I have to do is really setup a single datasource per index which points to the tribe and use a Custom Template variable to filter by datacenter.

Since tribes are really slow and heavy I’m trying to switch and use direct access to the ESs them selves, this makes me create multiple datasources (dc * index) at which point I’m not sure how can I change 2 datasources in the same board by changing a single templating variable.

I hope I explained myself better this time =)

Eugene Krapivin.

1.) In theory you can use ES alias - it supports multiple indices.


2.) Create structure in your TSDB, which will be used only for selecting right datasource name. For example:

region datasource_for_panel1 datasource_for_panel2
US us-app-logs us-sys-logs
EU eu-app-logs eu-sys-logs

And then play with visible/hidden dashboard variables.