Amazon CloudWatch can load all the metrics in your account (both AWS resource metrics and application metrics that you provide) for search, graphing, and alarms. Metric data is kept for 15 months, enabling you to view both up-to-the-minute data and historical data.
The CloudWatch monitoring provide some basic monitoring which can be configures in some clicks, while if you want to monitor custom metrics such as the disk and memory utilization of your EC2 machine you should have to follow these steps.
Steps to configure CloudWatch Metrics on Linux Machine:
- Go to AWS Console-> Go To IAM -> Go to Role-> create Role-> Attach CloudWatchAgentServerPolicy -> click next-> Give Role Name-> click create role
2. Attach created role to the EC2 instance on which you want to do configuration of CloudWatch Metrics.
Go to EC2-> Go to Security-> Go to Modify IAM Role-> Select the Role Name-> click on update IAM Role
3. SSH into Your EC2 instance and apply following Commands
The command will download CloudWatch Agent on your EC2 machine.
iI. sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
The Command will unzip the installed package
iiI. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
The Command start installation of CloudWatch Agent
iv. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
The Command will run the AWS CloudWatch Agent
v. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status
The Command Will start the AWS CloudWatch Configuration as per selected Settings.
4. Now monitor the instance from CloudWatch Console.
5. Go to the cloudwatch dashboard->click on all Metrics-> click on cwagent-> click on InstanceId
6. Select Metrics which utilization you want to check
7. This is how you can check the memory, disk and CPU utilization of your EC2 instance.