How to execute different queries depending on Custom variable value

  • What Grafana version and what operating system are you using?
    Grafana v11.1.4 on ubuntu-20.04

  • What are you trying to achieve?
    Want to execute a query when a specific Variable value is selected in the dashboard

  • How are you trying to achieve it?
    Created a custom variable called “Value”. Created two queries A and B. Trying to Execute query A when “Value” is selected as 10. and execute query B when “Value” is selected as 20.

  • What happened?
    Not able to perform the query depending on the selected value from variable.

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Did not get any error

  • Did you follow any online instructions? If so, what is the URL?

Hello [dharapushpendu],
We are working on a Grafana dashboard where the requirement is to execute different queries based on the value of a custom variable. For example:

  1. If the variable Value is set to 10, we want Query A to execute.
  2. If the variable Value is set to 20, we want Query B to execute.

Currently, we are facing an issue where the queries are not dynamically executing based on the selected variable value. Even though we have defined a custom variable (Value) in Grafana, we are not able to link it effectively with the queries.

Could you help us verify if there is a specific method or setting required to conditionally execute queries based on variable values in Grafana?

Thank you!"

You can follow this detailed document on how to to execute different query with custom variable value