0
votes

Is there a way to show deployment object label in prometheus alert rules?

I have a deployment object label set as teamname=teamA I want to show this label in KubeDeploymentReplicasMismatch alert.

I could do the same for pods related alerts by modifying expression with,

 * on(namespace,
  pod) group_left(label_axway_com_team) kube_pod_labels

I am unable to do the same for deployment object related alerts..

I also want to do this for daemonsets, statefulsets, cronjobs, jobs related alerts..But I am not sure if there is a way to show the Kubernetes object labels in the prometheus metrics ..I see a way only for pod labels.

Any help on this please?

1

1 Answers

0
votes

I have found using kube_deployment_labels help..

However the below expression is only showing the results of deployment objects that does not have the label.The same expression works for pods when I use Kube_pod_labels..

(kube_deployment_spec_replicas{job="kube-state-metrics",namespace=~".*"}
  != kube_deployment_status_replicas_available{job="kube-state-metrics",namespace=~".*"})
  and (changes(kube_deployment_status_replicas_updated{job="kube-state-metrics",namespace=~".*"}[5m])
  == 0) * on (deployment,namespace) group_left(label_axway_com_team) kube_deployment_labels 

What is the issue with this command?