0

I've created several elastic datasources in Grafana Elastic-fido2-${vertical}-events

How can I load it based on the $vertical variable so I use the same visual and not one for each $vertical?

I found this on grafana forum: https://community.grafana.com/t/how-to-use-template-variables-in-your-data-source/63250, but I do not find anywhere to add it in datasource or visual.

MortenB
  • 2,749
  • 1
  • 31
  • 35
  • Link which you posted here has little to do with this problem, unless you intend to create your own data source plugin. – markalex Aug 31 '23 at 11:13
  • I was hoping it was possible to create a `{{ template code }}` as a datasource – MortenB Aug 31 '23 at 11:19

1 Answers1

0

You cannot switch between different data sources based on unrelated variable.

But you can add Data source variable, that will allow you switch between data sources dynamically. And if you want to have a separate variable that contains a part of selected data source, you'll need to manage a bit of trickery with variable chaining.

How (and even if) it can be done depends on data sources available to you. Here is a general overview. But I'm afraid that if Elastic is the only type of data sources available to you at the moment, you wouldn't be able to create said variable chaining, and will be forced to fave to separate variables: one for data source and one for vertical, whatever it is.

markalex
  • 8,623
  • 2
  • 7
  • 32
  • The datasources are similar, but is not indexed together. One solution is to reindex elasticsearch to create one big index. But production do not want it. – MortenB Aug 31 '23 at 11:28
  • @MortenB, I meant variable of type [data source](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#add-a-data-source-variable). This way you could switch between your existing data sources. – markalex Aug 31 '23 at 11:30