Unable to execute query due to variables not decoding

i am using grafana 10.0.0v

  • What are you trying to achieve?
    i am getting sql query from a mysql table which i am storing in a variable and when i use the variable it should trigger the query present in the variable,it is working fine if it doesnt have any variables in the returned query,but if it has variables then it is not decoding the value instead it is passing the variable name itself to the query

  • How are you trying to achieve it?
    image
    in query panel i am using variable to get the query

  • What happened?


    when i run the query $best_cell_mro_kpi,$best_cell_ecgiID and $best_cell_mro_kpi should be replaced with actual values of variables which are already present in the dashboard

  • What did you expect to happen?
    i want to get the actual variable values in place to execute query,how do we do it

Welcome @saiteja05

Might try removing the single quote on that variable in the query

Hi @yosiasz , thanks for replying

If u see the query I am having other variables with out quotes even those are not getting replaced with value of variables

1 Like

can you please show us how those variables are created?


$best_cell_mro_kpi variable gives output string ( ecgiId_4_mro_kpi )


$best_cell_ecgiID variable gives output string (ecgiId_4) and similarly
$best_cell_clusterID gives (cluster10) as string

$best_cell_cdf variable contains this query
select formula_query from kpi_formula_values where query_name=‘best_cell_cdf’
and
kpi_name=‘handover_failure_rate’

and the formula_query returns actual query that i need to be implemented

why not abandon all of these variables and do it all in your main query as you are not displaying these variables to the user.

Can’t do that ,I am creating a dynamic dashboard based on selected kpi,query changes and other variable changes thats the reason I am going with this approach