Search code examples
grafanapromqlgrafana-variable

Grafana cannot resolve variable


I am using a dashboard variable name $project which can be project_A, project_B or All(or *) in Grafana.

Now, I want to write a query like

sum by (uri,status,method)(
 rate(http_server_requests_seconds_sum{team="myTeam",uri!="/actuator/prometheus",uri!="/actuator/health",project="$project"}[10m])  / 
 rate(http_server_requests_seconds_count{team="myTeam",uri!="/actuator/prometheus",uri!="/actuator/health",project="$project"}[10m]) 
)

This is giving me no output when I am setting $project=All. I am assuming this is because it cannot resolve the variable $project in both the functions because for a specific $project value it is successfully giving me output.

Am I guessing correct? What is the workaround of it?

Thanks in advance!


Solution

  • Change:

    project="$project"
    

    To:

    project=~"$project"