Create an alert based on the number container restarts on a period of time

Hi,
I’m trying to create an alert based on this “Excessive container restarts (>25% of target pod count over 2m)” but I haven’t been able to calculate this value so I’m wondering if you can help me with this.
Thanks

Hey @alejandro.garcia2,

What kind of containers are you working with?

You could use a NRQL Alert condition to count container restarts and adjust the time period and threshold to match what you would consider excessive restarts.

Using Kubernetes as an example, you could do something like this:

FROM K8sContainerSample SELECT max(restartCount) - min(restartCount) AS 'Restarts' 

Let us know if this helps.

Cheers!

Hi, I think I got what I want with this one

SELECT derivative(k8s.container.restartCount, 2 minute) / latest(k8s.deployment.podsDesired) FROM Metric

Thank you

@alejandro.garcia2 let us know how that works out for you!

1 Like

so far it works, thanks

1 Like