Trigger email / alert if server is giving 503 error

I am using Haproxy for few years on my site myupchar.com and we have seen that sometimes one of the server starts throwing 503 errors. Is there a way I can send an alert/email when let’s say there are 5-6 errors within let’s say 30 second time interval.

Let me know if that’s possible.

There might be a possibility from Lua to monitor backend stats using Proxy.gets_stats()

And then send email alert using using script from Thierry Fournier when specific condition is met (https://www.arpalert.org/how-to-send-email.html)

But there is no native way to do this AFAIK

Thanks @adarragon - I will try this out