user1578872
user1578872

Reputation: 9118

Prometheus query filter not working for OR filter

Is there any issue with the below query?

kube_resourcequota{resource="count/deployments.apps",type="hard",namespace="test1|test2"}

It works if I pass just one namespace.

kube_resourcequota{resource="count/deployments.apps",type="hard",namespace="test1"}

Sum also works without passing anything.

sum(kube_resourcequota{resource="count/deployments.apps",type="hard"})

Upvotes: 0

Views: 401

Answers (1)

Michael Doubez
Michael Doubez

Reputation: 6923

The instant vector selector can be expressed as

  • namespace="test1" to match label namespace exactly equal to "test1"
  • <no selector on namestapce> to match all values of namespace
  • namespace=~"test1|test2" to match label namespace with given regex

You made a mistake: you used a regex "test1[test2" with an exact match (=) instead of regex match (=~).

Correct expression would be:

kube_resourcequota{resource="count/deployments.apps",type="hard",namespace=~"test1|test2"}

Upvotes: 1

Related Questions