I have a variable environment, based on this variabele i want to select the datasource

I have a variabele defined of type custom:
image

I want to load the production elastic if I select production as value of the env variabele and for instance, if I select pre-production it selects that datasource.

Would this be possible?

Thanks in advance!

No direct answer for that, but possible… :slight_smile:

Thanks for the reply, would you have a direction to look for?

I think not possible directly as per this
Sorry for my answer, my bad…

I think no solution as per your requirement, perhaps you need to refine the requirement to achieve that with some work around.

I want to make some correction of my answer.
When I saw the https://play.grafana.org/d/5eue-XDGz/datasource-variable?orgId=1
You can achieve your requirment.

This is the direction:

  1. Create the datasource with name development-datasource01,development-datasource02,production-datasource02 and production-datasource02. I assume the same type
  2. In the dashboard variable create 1st variable
  • Fill the name with Environment, choose Type: Custom
  • Fill the Custom Options with development,production
  • Update the variable
  1. Create 2nd variable
  • Fill the name with Datasource, choose the Type: Datasource
  • Fill the Data Source Option with Elasticsearch
  • Fill the Inatance name filter with: $Environment
  • Update the Variable
  1. Back to dashboard and try to select the Environment, you will get the different datasource in the varibale Datasource
  2. In the Panel, choose the datasource $Datasource
  3. Create the query of the datasource.
1 Like

@fadjar340, thank you so much for your time, it works great!