Create a cloudwatch alarm if my running count in ecs service is 0

0

I have an ecs cluster with fargate as launch type and one service which has desired count as 1.

In somecase all my task may stop and there may a bug in the last updated code , hence the task will be created and deleted frequently. If this scenario happens I need to get notified. The desired count would be 1 , but the task keeps on deleting and creating as there may be any scenario that stops the container.

Bhavesh
已提問 1 年前檢視次數 659 次
1 個回答
0

You can use the Task state change events to send an alarm whenever the task changes its state to stopped.

You can use the AWS Event Bridge rule below:

{
  "source": ["aws.ecs"],
  "detail-type": ["ECS Task State Change"],
  "detail": {
    "lastStatus": ["STOPPED"]
    "clusterArn": ["$CLUSTER_ARN"]
  }
}

It will catch all stopped task events from the cluster provided. Please change the $CLUSTER_ARN with the respective cluster ARN.

I hope this helps you!

profile pictureAWS
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南