AWS ECS Task deployment failed alert using Amazon EventBridge

Akhil Ghatiki
2 min readOct 17, 2022

--

Amazon Elastic Container Service (ECS) is a highly scalable, high performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon Elastic Compute Cloud (Amazon EC2) instances.

We have recently decided to move our deployments to ECS. As, the uncle Ben said — With great power, comes great responsibility — setting up the monitoring and alerts for this new implementation was quite interesting and this blog post deep dives into one specific alarm that we configured i.e., How do you get alerted when an ECS task fails during the deployment ?

We had microsoft teams webhook in place, to which the alerts have to be sent when a failure / error occurs. This alert dump can be any other application in your case.

We have leveraged Amazon EventBridge rules for creating alerts when ever an ECS task fails. This gives us the opportunity to check what went wrong. Below is a high level block diagram of the implementation.

High level block diagram of alerting an AWS ECS task failure

And yes, I know what your eyes are looking for — The event rule pattern. Here is the pattern we used.

gist : https://gist.github.com/akhil-ghatiki/1251a54da8eaaca3c20f5322f5106319.js

You can use any pattern for your rule. In the above example, we are filtering it based on the group key whose value is the service name. So, any event with the service name will be sent to the SNS. Below is a sample event that can help you with other attributes you might need for your rule pattern.

gist : https://gist.github.com/akhil-ghatiki/e2654a551d6989ed0cb652318357f20b.js

God Speed !!

--

--

Akhil Ghatiki
Akhil Ghatiki

Written by Akhil Ghatiki

Developer at ThoughtWorks. Sometimes ENTP-T and sometimes ESTP-A not sure which one.Loves to talk about tech, code, data privacy, environment.

No responses yet