0

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

  • namespace is defined as: foo: app1|app2|app3
  • service is defined as: list of app4, app5, app6

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?

3
  • I struggle to understand first part of you question were you explain your variables. Consider working on formatting a bit more in future. Commented Jun 19 at 22:33
  • 1
    Regarding the question itself, I'd say manual or (pipe) is the right way. If having series with empty app is the only concern (and assuming non of variables can properly contain empty variable) you can just add a second selector app!=""to your query. Commented Jun 19 at 22:37
  • @markalex Thank you! Its exacrly what i need, app!="" I really appreciate your answer! Commented Jun 23 at 7:41

1 Answer 1

-1

add selector app!=""

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.