Suppress alert when restarting

Tobias Langner via This is the general mailing list for monit <[email protected]> Sun, 9 Feb 2025 22:11:30 +0100
Newsgroups gmane.comp.monitoring.monit.general
Message-ID <[email protected]>
Hey,

I use monit to monitor the health of a bunch of docker containers that 
sometimes die/become unhealthy for various reasons, when they are 
configured to be restarted by monit, which most of the time fixes the issue.

I'd like to only be notified by monit when the restart does not fix the 
problem and the container is still unhealthy. I thought to configure 
something like

CHECK PROGRAM MyContainer PATH /bin/check_container my_container
   if status != 0 for 5 cycles then restart
   if status != 0 for 10 cycles then alert
   ...

in the hope that I would only get notified when the script returns a 
failure for 10 cycles. However, I also get a notification after five 
cycles, usually followed by one immediately after, telling me that 
everything is good again.

How can I configure monit in a way to not get notified in such a case? 
One way I came up with was to create to separate rules, one to restart 
only that uses noalert to entirely supress alerts, and another one to 
alert. But that seems like overkill.

Thanks for your help, best,

   Tobias

PS: My request is the same as in this thread 
<https://lists.nongnu.org/archive/html/monit-general/2014-05/msg00016.html> 
but since a) the solution there does not work for me as I generally 
don't have an execution failure and b) it is more than 10 years old, I 
thought to rather create a new thread.