The default monitoring of Amazon EC2 does not track the EBS disk space. To monitor disk space in EC2 instance, you need can either manually installed Cloudwatch Agent or can use SSM to install the agent. After installing you
Step 1. Instal cloudwatch agent
sudo yum -y install amazon-cloudwatch-agent
Step 2. create a config.json file in the following location.
/opt/aws/amazon-cloudwatch-agent/bin/config.json
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"disk": {
"measurement": [
"used_percent"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
}
}
}
}
3. Run the agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
4. check the status of the agent.
systemctl status amazon-cloudwatch-agent
Troubleshooting
If there is an issue starting the agent, you can have a look at the Cloudwatch logs at var/log/amazon/amazon-cloudwatch-agent