Get in Touch
Custom EC2 CloudWatch Metrics For Memory and Disk Utilization
09 August 2024
Tech
Table of contents
Custom EC2 CloudWatch Metrics for Memory and Disk Utilization
- Memory (RAM) Usage.
- Disk Usage.

What is a CloudWatch Agent?
Create Role for EC2 Instance
- Go to IAM → Roles → Create Role → AWS Service → EC2 → Select `CloudWatchAgentServerPolicy` → Name: CloudWatchAgentRole → Create.

Configure CloudWatchAgent on EC2 instance
- SSH to your EC2 instance and run the following script to install the cloudwatch agent. (Here I am using Ubuntu Server)
Wget
https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
sudo apt-get update
- Edit amazon-cloudwatch-agent.json file: sudo nano /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
- Copy the following script in .json file.
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "cwagent"
},
"metrics": {
"append_dimensions": {
"InstanceId": "${aws:InstanceId}"
},
"metrics_collected": {
"disk": {
"measurement": [
"used_percent"
],
"metrics_collection_interval": 60,
"resources": [
"/"
]
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
}
}


References
More
An interesting read? Here is more related to it.
12 August 2024
Pruthvi MenparaPermanently Blocking IP Addresses with AWS WAF Rate-Based Rule Limit
Tech
Web
Making IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
Making IT Possible
India (HQ)
201, iSquare Corporate Park, Science City Road, Ahmedabad-380060, Gujarat, India
For Sales
[email protected]
Looking For Jobs
Apply Now
LinkedIn
Instagram
X
Facebook
Youtube
Discord
Dribbble
Behance
Github