How can I monitor high memory utilization for Amazon ECS tasks on Fargate?
I want to monitor high memory utilization for Amazon Elastic Container Service (Amazon ECS) tasks running on AWS Fargate.
"I want to monitor high memory utilization for Amazon Elastic Container Service (Amazon ECS) tasks running on AWS Fargate.ResolutionTo monitor high memory utilization on your Amazon ECS tasks on Fargate, try the following options:View Amazon CloudWatch metricsView Amazon CloudWatch metrics in either the Amazon ECS console or CloudWatch console.Note: Any Amazon ECS service that uses the Fargate launch type is automatically enabled for Amazon CloudWatch memory and CPU utilization metrics.Enable CloudWatch logs for your Fargate tasks1.    Enable the awslogs log driver.2.    Add the required log configuration parameters to your task definition.3.    Give the Amazon ECS task execution for your AWS Identity and Access Management (IAM) role the permissions to send logs to Amazon CloudWatch Logs.4.    View your logs in the CloudWatch console.Note: Your tasks must enter the Running state before you can view your logs.Use Container Insights to monitor memory utilizationYou can use CloudWatch Container Insights to monitor memory utilization for each container in a Fargate task.1.    Open the CloudWatch console.2.    From the navigation pane, in the Container Insights section, choose Resources.3.    To get more information about a resource, choose the name of the resource.Note: Tasks are grouped by the task definition for each cluster.4.    Choose the name of the task definition that you want more information about.5.    In the Container Performance section, choose Actions, and then choose View performance logs. This opens CloudWatch Logs Insights for your ECS cluster.6.    In the query box, enter the following query, and then choose Run query:stats avg(MemoryUtilized) by bin (30m) as period, TaskDefinitionFamily, TaskDefinitionRevision                | filter Type = "Task" | sort period desc, TaskDefinitionFamily |  limit 10Use Container Insights to set an alarm on high memory utilization1.    Open the CloudWatch console.2.    From the navigation pane, in the Container Insights section, choose Performance Monitoring.3.    From the dropdown menu, choose ECS Tasks or ECS Services.4.    On the Memory Utilization card, choose the expander (vertical dots), and then choose View in Metrics.5.    Choose the Graphed metrics tab, and then choose the bell icon in the Actions column for the task that you want more information about.6.    On the Specify metric and conditions page, choose your desired values or leave the default values.7.    In the Conditions section, for Define the threshold value, enter 70. This sets the alarm's memory utilization threshold to 70%.8.    Choose Next.9.    On the Configure actions page, in the Select an SNS topic section, select Create new topic.10.    For Send a notification to, enter the email ID where you want the alarm notifications sent.11.    Choose Next.12.    On the Add name and description page, for Alarm name, enter a name for your alarm. 13.    (Optional) For Alarm description, enter a description for your alarm.14.    Choose Next, and then choose Create alarm.15.    Confirm your subscription by following the instructions in the confirmation email that you receive from AWS.Note: CloudWatch doesn't automatically create all possible metrics from the log data to help you manage your Container Insights costs. You can view additional metrics and additional levels of granularity by using CloudWatch Logs Insights to analyze the raw performance log events.Related informationAmazon ECS on AWS FargateIntroducing Amazon CloudWatch Container Insights for Amazon ECSHow Amazon ECS manages CPU and memory resourcesFollow"