Hi,
I have a Prometheus alerting rule like this:
alert: wrong_number_of_pods
expr: kube_deployment_status_replicas_available{namespace="abc"} != 2
for: 3m
annotations:
description: 'Deployment: {{ $labels.deployment }} has wrong number of pods running.'
summary: 'Deployment: {{ $labels.deployment }} has wrong number of pods running.'
I'm trying to apply this rule to two namespaces - "abc" and "def-xyz". Note that the second namespace has a hyphen in it's name.
I'm wondering if it is possible to use regex to specify both the namespaces - may be something like this: expr: kube_deployment_status_replicas_available{namespace="abc"|"def-xyz"} (although this exact expr doesn't work).
The alternate approach is to include the two namespaces in relabel-configs. Right now, my relabel-config looks like this:
- source_labels: [__meta_kubernetes_namespace]
regex: abc
action: keep
How should I change the regex above to include both "abc" and "def-xyz"? Is it like this?
- source_labels: [__meta_kubernetes_namespace]
regex: abc | def-xyz
action: keep
Thanks.