Prometheus alert expression to check the status of a service having 3 pods

63 Views Asked by At
  1. The following expression shows that the service "name" has 3 pods sum by (namespace, created_by_name) (kube_pod_info)

    {created_by_name="name", namespace="ns"} 3

  2. The following expression lists the 3 pods

    sum by (namespace,created_by_name,pod) (kube_pod_info)

    {created_by_name="name ", namespace="ns", pod="name-2"} 1 {created_by_name="name", namespace="ns", pod="name-1"} 1 {created_by_name="name", namespace="ns", pod="name-0"} 1

Assuming that "name-0" is down, which prometheus alert expression can show that:

  • "name-0" is down and "name-1" & "name-2" are up?
  • For service "name", 1 pod out of 3 is down?

Thank you

The following expression is showing that "name-0" is down. But it doesn't tell that there is 2 others pods that are up.

max_over_time(kube_pod_container_status_waiting_reason{namespace=~".*"}[5m])

0

There are 0 best solutions below