- Newest
- Most votes
- Most comments
Hello.
Are all the containers in your ECS service set to "essential=true"?
If so, EventBirdge will be able to catch an event when a container stops.
https://repost.aws/articles/AR8VnJ5IN5R6i2GNYbLwEdxw/how-to-notify-by-email-when-the-exitcode-of-an-ecs-fargate-task-ends-with-a-value-other-than-0
The documentation also recommends setting an alarm on RunningTaskCount, which is included in the Container Insights metrics.
Since it's difficult for you to use Container Insights, I think that if you can't use EventBridge, you would need to create a script using Lambda or something to periodically check the status of your ECS service.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS-ContainerInsights
You can use EventBridge Rules to enable notification. Go to EventBridge > Rules New Rule.
For rule, use JSON event pattern
{
"source": ["aws.ecs"],
"detail-type": ["ECS Service Action"],
"detail": {
"eventType": ["SERVICE_TASK_STATE_CHANGE"],
"lastStatus": ["STOPPED"]
}
}
For target, use a SNS topic when the event is matched. A notification will be sent to SNS. You can either trigger a Lambda function or simply get an email notification.
Relevant content
- asked 2 years ago
