AWS kind of sucks when it comes to monitoring Memory and Disk usage on EC2, as in they don't provide it out of the box.
AWS instead gives you a set of perl scripts to do this via CloudWatch custom metrics.
Details are here:
Monitoring Memory and Disk Metrics for Amazon EC2 Linux Instances
The following is the actual steps used to get Disk/Memory stats into CloudWatch
First, create an IAM user who has permissions to the following:
- cloudwatch:PutMetricData
- cloudwatch:GetMetricStatistics
- cloudwatch:ListMetrics
- ec2:DescribeTags
Create an AccessKey/SecretKey under this user. Then do the steps below per instance.
This is on AMI Linux
> sudo yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https -y
> sudo yum -y install perl-Digest-SHA # not documented, was needed on at least 1 AMI EC2
> curl https://aws-cloudwatch.s3.amazonaws.com/downloads/Clou dWatchMonitoringScripts-1.2.2.zip -O
> unzip CloudWatchMonitoringScripts-1.2.2.zip
> cd aws-scripts-mon
> cp awscreds.template awscreds.conf
> vi awscreds.conf
Add AccessKey/SecretKey to awscreds.conf. Then add something like this to crontab:
*/5 * * * * ~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-util --disk-space-util --disk-path=/ --from-cron
Then go into CloudWatch and create dashboard.