How to exclude multiple labels from Prometheus Query?
Asked Answered
T

2

14

I want to exclude mulitple app groups from my query... Not sure how to go about it.. My thoughts are like this

count(master_build_state{app_group~! "oss-data-repair", "pts-plan-tech-solution", kubernets_namespace = "etc"} ==0) 

I do not want to include those two app_groups, but am not sure how to implement in PromQL. You would thing to add () or [], but it throws errors. Let me know if anyone can help!

Thanks

Tarrasa answered 6/8, 2021 at 12:39 Comment(0)
T
19
count(master_build_state{app_group !~ "(oss-data-repair|pts-plan-tech-solution)", kubernets_namespace="etc"} ==0)
Tarrasa answered 6/8, 2021 at 17:59 Comment(1)
~! should be !~Sanguineous
W
9

you can use the != comparison binary operator to do that. Just write it twice on your promQL.

count(
  master_build_state{
    app_group!="oss-data-repair", 
    app_group!="pts-plan-tech-solution",
    kubernets_namespace="etc"} 
== 0) 
Wagram answered 6/8, 2021 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.