prometheusgrafana

How to implement OR logic for Grafana variables?


I have 2 variables in my Grafana: namespace and service.

I've got a metric named http_request_count with label app. I want to implement the following query in my Grafana panel:

http_request_count{app = namespace or service}

When the user selects both the namespace and service variables, I want it to be piped together so the metric is calculated for all services. But, when the user selects either of the variables, its values must be piped.

If I write something like the following: http_request_count{app = "${namespace}|${service}"} then, when the user doesn't choose namespace it will be empty and a time series with an empty app label value will be selected(I want to exclude time series having an empty app label value).

How can I implement this logic correctly?


Solution

  • add selector app!=""