Using k8s labels in prometheus rules expr #2338
Labels
lifecycle/stale
Denotes an issue or PR has remained open with no activity and has become stale.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
Hello,
I am new to Prometheus so I would ask for some advice.
I am trying to use custom labels from k8s deployment in the prometheus rules expression.
Here is my setup:
k8s labels:
labels:
app: nginx-test
ignore-desired-replicas: "true"
ignore-ram-usage: "true"
ignore-cpu-usage: "true"
ignore-container-restarts: "true"
team: xxx
kube-state-metrics deployment.
args:
- '--metric-labels-allowlist=pods=[team, ignore-ram-usage, ignore-cpu-usage, ignore-container-restarts],deployments=[team, ignore-desired-replicas],persistentvolumeclaims=[team]'
Prometheus rule
expr: kube_deployment_labels * on (deployment, namespace) group_right(label_team) ((kube_deployment_status_replicas_available / kube_deployment_spec_replicas) < 1 )
I also tried to add group_right(label_team, ignore-desired-replicas) and ( (label_team, label_ignore-desired-replicas), but I am not even able to startup the container, I assume due to the fact that it does not recognize the label.
It looks to me that I am making a mistake somewhere in the kube-state-metrics configuration.
Currently, when I receive an alert I can see that it groups only be team and it is ignoring my second label ignore-desired-replicas.
Any thoughts, folks?
The text was updated successfully, but these errors were encountered: