Reputation: 107
I have a custom variable "Project_Name" in Grafana Dashboard. I want to execute below condition unsing Promql query in Stackdriver Metrics datasource(GCP)
if ($Project_Name == 'ALL') then :
sum(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment'}[$__interval]))
else
sum by (project_id)(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment',project_id="$Project_Name"}[${__interval}]))
I tried to execute below queries but getting different errors, any help to find the right solution will be greatly appreciated. Thanks in advance.
${Project_Name:regex} == "ALL" and sum(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment'}[$__interval])) or sum by (project_id)(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment',project_id="$Project_Name"}[${__interval}]))
sum(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment'}[$__interval])) unless on() (${Project_Name} == "ALL") or sum by (project_id)(avg_over_time(composer_googleapis_com:environment_active_schedulers{monitored_resource='cloud_composer_environment',project_id="$Project_Name"}[${__interval}]))
Also, is it possible execute both the query in grafana depending on the variable? May be hide one queryA output when Project_Name != "ALL" and hide queryB output when Project_Name == "ALL" ?
Upvotes: 0
Views: 51