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:

3️⃣ Verify Metrics in CloudWatch

After installing and starting the agent:

  1. Go to AWS Console → CloudWatch → Metrics → CWAgent.
  2. 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
  3. Ensure metrics update at the interval you configured (default 60 seconds).

4️⃣ Create CloudWatch Alarms for Critical Thresholds

🔹 Alarm for EBS Volume Usage (≥ 80%)

  1. Navigate to CloudWatch → Alarms → Create Alarm.
  2. Select metric: CWAgent → disk_used_percent → choose EBS volume.
  3. Set threshold: ≥ 80%.
  4. Configure actions:
    • Create or select an SNS topic.
    • Add email addresses or Lambda functions to automate alerts.
  5. Name the alarm and save.

🔹 Alarm for CPU Utilization (≥ 80%)

  1. Navigate to CloudWatch → Alarms → Create Alarm.
  2. Select metric: EC2 → Per-Instance Metrics → CPUUtilization.
  3. Set threshold: ≥ 80%.
  4. Configure actions via SNS.
  5. 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

6️⃣ Optional: Automate Across Multiple Instances with SSM

References

← Back to Blogs