How to Send Alerts When EBS Volume, CPU, or Other Metrics Reach Critical Levels on EC2
By Bishal Dhimal | Dec 2025
📌 Table of Contents
1. Install & Configure CloudWatch Agent
2. Create IAM Role for CloudWatch Agent
3. Verify Metrics in CloudWatch
4. Create CloudWatch Alarms
5. Best Practices for Alerts
6. Optional: Automate with AWS SSM
References
1️⃣ Install & Configure CloudWatch Agent
The CloudWatch Agent allows you to collect system-level metrics such as CPU, memory, disk usage, and optionally network metrics. Follow these steps:
Step 1: Install CloudWatch Agent
# For Amazon Linux / RHEL
sudo yum install -y amazon-cloudwatch-agent
# For Ubuntu / Debian
sudo apt-get install -y amazon-cloudwatch-agent
Step 2: Configure the Agent
You can use the wizard or create a custom JSON config:
sudo amazon-cloudwatch-agent-config-wizard
Or define a custom configuration for metrics collection:
cat <<EOF | sudo tee /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
{
"agent": {
"metrics_collection_interval": 60,
"logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
},
"metrics": {
"namespace": "CWAgent",
"metrics_collected": {
"disk": {
"measurement": ["used_percent"],
"metrics_collection_interval": 60,
"resources": ["*"]
},
"mem": {
"measurement": ["mem_used_percent"],
"metrics_collection_interval": 60
},
"cpu": {
"measurement": ["cpu_usage_idle","cpu_usage_user","cpu_usage_system"],
"metrics_collection_interval": 60,
"totalcpu": true
},
"net": {
"measurement": ["bytes_sent","bytes_recv"],
"metrics_collection_interval": 60,
"resources": ["*"]
}
}
}
}
EOF
💡 Tip: Collecting network and CPU breakdown metrics is optional but helpful for detecting network spikes or CPU bottlenecks.
2️⃣ Create IAM Role with Necessary Permissions
CloudWatch Agent needs permissions to report metrics and send alerts:
- Create an IAM Role for the EC2 instance.
-
Attach the following policies:
- CloudWatchAgentServerPolicy – allows publishing metrics.
- AmazonEC2ReadOnlyAccess – allows agent to read EC2 metadata.
- AmazonSSMManagedInstanceCore – required if using SSM to manage multiple servers.
- AmazonSNSFullAccess – required to send notifications via SNS.
- Attach the IAM role to your EC2 instance.
3️⃣ Verify Metrics in CloudWatch
After installing and starting the agent:
- Go to AWS Console → CloudWatch → Metrics → CWAgent.
-
Check that the following metrics are reported:
- Disk usage (used_percent)
- Memory usage (mem_used_percent)
- CPU usage (cpu_usage_user, cpu_usage_system, cpu_usage_idle)
- Optional: Network traffic metrics
- Ensure metrics update at the interval you configured (default 60 seconds).
4️⃣ Create CloudWatch Alarms for Critical Thresholds
🔹 Alarm for EBS Volume Usage (≥ 80%)
- Navigate to CloudWatch → Alarms → Create Alarm.
- Select metric: CWAgent → disk_used_percent → choose EBS volume.
- Set threshold: ≥ 80%.
-
Configure actions:
- Create or select an SNS topic.
- Add email addresses or Lambda functions to automate alerts.
- Name the alarm and save.
🔹 Alarm for CPU Utilization (≥ 80%)
- Navigate to CloudWatch → Alarms → Create Alarm.
- Select metric: EC2 → Per-Instance Metrics → CPUUtilization.
- Set threshold: ≥ 80%.
- Configure actions via SNS.
- Name the alarm and save.
🔹 Optional: Memory & Network Alarms
You can create alarms for memory usage or network bandwidth using CWAgent metrics collected:
CWAgent → mem_used_percent
CWAgent → net_bytes_sent
CWAgent → net_bytes_recv
5️⃣ Best Practices for Alerts
- Set multiple thresholds (e.g., warning at 70%, critical at 90%) for proactive alerts.
- Combine with AWS SNS → Slack/Email for fast notifications.
- Use descriptive alarm names (e.g., EC2-WebServer1-CPU-80%) for clarity.
- Regularly review metrics to avoid alert fatigue.
6️⃣ Optional: Automate Across Multiple Instances with SSM
- Store your CloudWatch Agent JSON config in SSM Parameter Store.
-
Deploy config to multiple EC2 instances:
sudo amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:AmazonCloudWatch-linux -s - This ensures uniform metric collection and alarm setup across instances.