Get in touch with us
Cloud consulting is what we do best - whether it's about taking your business to the next level or working for us we'd love to hear from you.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Monitor Memory Usage of your EC2 Instance with CloudWatch

David So
October 6, 2020

As we all know, monitoring EC2 instance is a vital part of managing and administering AWS resource, with the benefit of AWS CloudWatch, it allows the user to have visibility into how our resources are behaving and provides realtime dashboards to get valuable information. Some of the main Benefits of CloudWatch metrics are:

for our recommended levels of CPU usage, or storage usage, and alerts us when alarms break.

·       Generates alert on CloudWatch so that the system is proactively monitoring to pre-empt possible issue,

·       To make your application more secure with constant security detect,

·       It can help you monitor the resultant performance and cost of your application,

·       Troubleshooting and recommendation for future and how to avoid the existing errors.

One thing you may notice is that from the list of Instance Metric within AWS Documentation, any metric related to memory consumption is not provided by default, this is a crucial piece of information for system administrator to review especially with database running. This is possibly due to the fact that metrics provided by AWS are collected at the hypervisor level comparing to memory metrics (like disk IOPS) is from the OS level, hence it is a custom metric that you have to periodically push toCloudWatch.

To obtain memory metric, you can install a custom monitoring script which will provide you statistics including memory, swap, and disk space utilization. The high-level steps are:

*applicable for Amazon Linux/Ubuntu/ SUSE/Red Hat instance

1.     Ensure script have permission to call CloudWatch action with the associate instance IAM role,  

2.     Connect to the instance and Install theRequire Packages,

3.     Install Monitoring Script “”,

4.     Run the script with your desired option, e.g. to get utilization statistics for the last 12 hours, run the command:


5.     Following is a snippet of the output:

After you successfully run the script, you can view your custom metrics in the Amazon CloudWatch console.

1.     Run as described previously.

2.     Open the CloudWatch console at

3.     Choose View Metrics.

4.     For Viewing, your custom metrics posted by the script are displayed with the prefix System/Linux.

With the ability to monitor Memory consumption, you will obtain an extensive review of your instance without the need to establish a manual connection, this result in more efficient management in time saving manner and even more precise recommendations.

To find more in detail and where to download the script, kindly visit Configure Monitor memory /diskmetric EC2 Linux .

You can also configure other custom CloudWatchmetric explained in here.

David So
David is a IT Support Engineer with more than 10 years of experience in infrastructure planning, deployment, administering and troubleshooting of various operating system in an Enterprise environment. This can include but not limited to; firewall/ network configuration, Active Directory and Exchange, Clustering architecture, Storage/SAN Management Products, Backup and Disaster Recovery to the Clouds for Microsoft Azure and AWS.

Recent Blog Posts