How to monitor EC2 instances by memory?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
EC2 does not publish memory usage to CloudWatch by default. If you want to monitor EC2 instances by memory, you need an agent inside the instance, and the standard AWS answer is the CloudWatch agent.
Why Memory Is Not Available by Default
CloudWatch automatically provides instance-level metrics such as CPU, network, and disk activity because those can be observed from the infrastructure layer. Memory usage is an operating-system-level metric, so AWS needs help from software running inside the guest.
That is why “EC2 memory monitoring” really means “install something in the instance that emits memory metrics.”
Use the CloudWatch Agent
The usual AWS approach is the CloudWatch agent. Once installed and configured, it can publish memory statistics along with other OS-level metrics.
A typical configuration includes a memory section such as:
After the agent starts, CloudWatch can alarm on those custom instance memory metrics.
Alarm on the Published Metric
Once memory is in CloudWatch, treat it like any other metric:
- create dashboards
- add alarms
- wire notifications to SNS
- use the signal for autoscaling or operations response if appropriate
The key operational milestone is not just “metric exists,” but “alerts and dashboards are actually using it.”
Common Pitfalls
- Expecting EC2 memory usage to appear in CloudWatch automatically without an in-instance agent.
- Installing the agent but forgetting to configure memory metrics specifically.
- Publishing the metric but never creating alarms or dashboards for it.
- Assuming CPU pressure always correlates with memory pressure.
- Treating one memory percentage number as sufficient without considering swap, application behavior, and workload context.
Summary
- EC2 memory is not a default CloudWatch metric.
- You need an in-instance agent, typically the CloudWatch agent.
- Configure the agent to publish memory metrics such as used percent.
- Once published, monitor and alarm on those metrics like any other CloudWatch signal.
- Effective memory monitoring is agent setup plus operational use, not just metric collection.
Related reading
- How to mount a postgresql volume using Aws EBS in Kubernete
- How to mount EFS on a Lambda function?
- How to move a domain from Godaddy to AWS Route 53
- How to move all files and folder from one folder to another of S3 bucket in php with some short way?
- How to monitor JMX metrics of Kafka broker on command line?
- How to monitor messages rate in Kafka topics?
- How to move files from amazon ec2 to s3 bucket using command line
- How to normalize a private key stored on AWS secrets manager

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.