Find out name of container that restarted, using Prometheus

11/26/2020

Currently I am using the following query

sum(rate(kube_pod_container_status_restarts_total{namespace="default"}[5m]))

to get alerted when 1 or more container get restarted in default namespace.

This gives me the number of containers that restarted but not their names. Is there a way to get the name of containers that restarted?

Thanks you.

-- Aalok
kubernetes
prometheus

1 Answer

11/26/2020

Try the below query

sum (changes (kube_pod_container_status_restarts_total[1m])) by (container,container_name,endpoint,instance,job,name,namespace, pod, pod_name,service)
-- P Ekambaram
Source: StackOverflow