Get in Touch
Custom EC2 CloudWatch Metrics For Memory and Disk Utilization
Written by Nishant Parmar
Published09 August 2024
Tech
Set up custom CloudWatch metrics for your EC2 instances to monitor memory and disk utilization. Simplify your resource management with ease.
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.
Permanently Blocking IP Addresses with AWS WAF Rate-Based Rule Limit
12 August 2024
/
Nishant Parmar
Tech
Web Development
AWS G and P Series EC2 Instances: Rendering, Gaming and Machine Learning
12 November 2024
/
Nishant Parmar
Tech
How to Create Dynamic DNS in AWS Route 53 Using Python and the AWS SDK
13 September 2024
/
Nishant Parmar
Web Development
Tech
Nuxt 3 & Brotli Compression: A Deep Dive Into Hydration Mismatch Solutions
31 August 2023
/
Jay Bharadia
Tech
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
We Make pixel perfect things
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