How to Monitor Memory Utilization of ECS Tasks in AWS Fargate

XD
4 min readMar 8, 2023

--

AWS Fargate is a serverless computing platform that allows users to run containers without managing the underlying infrastructure. It offers a convenient way to deploy, manage, and scale containerized applications. However, like any other computing platform, it is essential to monitor the resources used by your containers to ensure optimal performance and prevent downtime. In this article, we will discuss how to monitor the memory utilization of ECS tasks in AWS Fargate using Container Insights and set an alarm for high memory utilization.

Step 1: Use Container Insights to set an alarm on high memory utilization

  • Open the CloudWatch console.
  • From the navigation pane, in the Container Insights section, choose Performance Monitoring.
  • From the dropdown menu, choose ECS Tasks or ECS Services.
  • On the Memory Utilization card, choose the expander (vertical dots), and then choose View in Metrics.
  • Choose the Graphed metrics tab, and then choose the bell icon in the Actions column for the task that you want more information about.
  • On the Specify metric and conditions page, choose your desired values or leave the default values.
  • In the Conditions section, to Define the threshold value, enter 70. This sets the alarm’s memory utilization threshold to 70%.
  • Choose Next.
  • On the Configure actions page, in the Select, an SNS topic section, select Create a new topic.
  • For Send a notification to, enter the email ID where you want the alarm notifications sent.
  • Choose Next.
  • On the Add name and description page, for the Alarm name, enter a name for your alarm.
  • (Optional) For Alarm description, enter a description for your alarm.
  • Choose Next, and then choose to Create alarm.
  • Confirm your subscription by following the instructions in the confirmation email that you receive from AWS.

Step 2: Understand the mm1m0 * 100 / mm0m0 expression

Once you have set up the alarm, you may wonder how AWS CloudWatch calculates memory utilization. AWS CloudWatch calculates memory utilization using the following expression: mm1m0 * 100 / mm0m0. Here, mm1m0 represents the average memory usage of a particular resource over a 1-minute period, and mm0m0 represents the maximum memory available to that resource. The expression calculates the percentage of memory being used by that resource at a given point in time, based on the average memory usage over the last minute and the maximum memory available. For example, if mm1m0 is 500 MB and mm0m0 is 1 GB, then the expression mm1m0 * 100 / mm0m0 would calculate the memory utilization as 50%.

Step 3: Set an alarm for high memory utilization

To set an alarm for high memory utilization, you can use Amazon SNS to receive notifications when memory utilization exceeds a certain threshold. For example, you can set an alarm when memory utilization exceeds 80% with the following alarm name: High Memory Utilization.

In conclusion, monitoring memory utilization is essential for optimizing the performance of your ECS tasks in AWS Fargate. By using Container Insights and setting an alarm for high memory utilization, you can ensure that your containerized applications run smoothly and avoid potential downtime.

for testing the notification email, set threshold to 0, you will receive email instantly after saving

Voilla 🎉

--

--

XD
XD

Written by XD

Code by day, hack the system by night. Navigating the cloud like a neon-lit alleyway. APIs, bugs, and glitches – I fix what the future breaks.

Responses (2)