Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EC2 CloudWatch memory metrics don't match what Top shows

I have a t2.micro EC2 instance, running at about 2% CPU. I know from other posts that the CPU usage shown in TOP is different to CPU reported in CloudWatch, and the CloudWatch value should be trusted.

However, I'm seeing very different values for Memory usage between TOP, CloudWatch, and NewRelic.

There's 1Gb of RAM on the instance, and TOP shows ~300Mb of Apache processes, plus ~100Mb of other processes. The overall memory usage reported by TOP is 800Mb. I guess there's 400Mb of OS/system overhead?

However, CloudWatch reports 700Mb of usage, and NewRelic reports 200Mb of usage (even though NewRelic reports 300Mb of Apache processes elsewhere, so I'm ignoring them).

The CloudWatch memory metric often goes over 80%, and I'd like to know what the actual value is, so I know when to scale if necessary, or how to reduce memory usage.

Here's the recent memory profile, seems something is using more memory over time (big dips are either Apache restart, or perhaps GC?)

Screenshot of memory usage over last 12 days

like image 340
Claude Avatar asked Nov 09 '22 17:11

Claude


1 Answers

AWS doesn't supports Memory metrics of any EC2 instance. As Amazon does all his monitoring from outside the EC2 instance(servers), it is unable to capture the memory metrics inside the instance. But, for complete monitoring of an instance, you must need Memory Utilisation statistics for any instance, along with his CPU Utilisation and Network IO operations. But, we can use custom metrics feature of cloudwatch to send any app-level data to Cloudwatch and monitor it using amazon tools. You can follow this blog for more details: http://upaang-saxena.strikingly.com/blog/adding-ec2-memory-metrics-to-aws-cloudwatch

You can set a cron for 5 min interval in that instance, and all the data points can be seen in Cloudwatch.

like image 170
upaang saxena Avatar answered Nov 14 '22 22:11

upaang saxena