I am trying to create a variable in Grafana using below query to return me a number based on cpu usage percentage. This works fine for panels but it throws an error when I try to create a variable out of it.
(vector(1) and on() (sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate)/0.04)<50)
or on() (vector(2) and on() (sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate)/0.04)<80)
or on() vector(3)
You have a couple of problems here:
query_result
is used.I reproduced your error with similar query, and it began to work correctly, once new-lines were removed.
My query:
query_result((vector(1) and on() (sum(node_cpu_seconds_total)/0.04)<1000000000) or (vector(2) and on() (sum(node_cpu_seconds_total)/0.04)<8000000000) or vector(3))
Tested at play.grafana.com