Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude multiple labels from Prometheus Query?

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

like image 644
ColeGulledge Avatar asked Dec 29 '25 00:12

ColeGulledge


2 Answers

count(master_build_state{app_group !~ "(oss-data-repair|pts-plan-tech-solution)", kubernets_namespace="etc"} ==0)
like image 137
ColeGulledge Avatar answered Dec 30 '25 22:12

ColeGulledge


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) 
like image 37
Felipe Avatar answered Dec 30 '25 22:12

Felipe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!