How can I obtain metrics from Amazon CloudWatch that show the EBS throughput of my EC2 instance, and then set up an alarm that notifies me when the EC2 instance reaches the throughput limit?

Last updated: 2020-08-20

How can I obtain metrics from Amazon CloudWatch that show the aggregate Amazon Elastic Block Store (Amazon EBS) throughput of my Amazon Elastic Compute Cloud (Amazon EC2) instance? Also, how can I then set up an alarm that notifies me when the EC2 instance has reached the throughput limit?

Short description

There isn't a native Amazon EBS metric that tracks the EBS throughput of a Xen-based Amazon EC2 instance in CloudWatch. However, you can use the EC2EBSThroughput/ script to measure the aggregate EBS throughput of your EC2 instance.

The script collects the total read/write bytes per second across all attached volumes, and pushes the throughput as a metric to Amazon CloudWatch. You can then view the metrics in the Amazon CloudWatch console and set an alarm that triggers based on a threshold that you specify.

Note: The new Nitro instances, M5 and C5, include the CloudWatch metrics EBSIOBalance% and EBSByteBalance%. For more information, see Amazon EBS-Optimized instances.

The script is for Xen-based EC2 instances in CloudWatch. The script is compatible only with Amazon Linux, Red Hat Enterprise Linux, and CentOS instances. However, you can customize the script for other Linux distributions.

Note: If your instance has an instance store volume, the script reports aggregate throughput, including the throughput of the instance store volume. This means that you might not get an accurate measurement of the EBS throughput from this script.


1.    For RHEL-based distributions, install the AWS Command Line Interface (AWS CLI), if you haven't already done so.

2.    Download the script.

3.    Place the script on your instance, and then make it executable. You must run the script as a root user or sudo. Otherwise, it will fail.

$sudo chmod +x 

4.    From the AWS CLI, set the desired runtime frequency by running the following command in the background:

$sudo nohup ./ example-sleep-interval &

Note: Replace example-sleep-interval with the desired number of seconds between each data point.

5.    Create an IAM role.

6.    Attach the following policy to the role:

  "Version": "2012-10-17",
  "Statement": [{
    "Action": [
    "Effect": "Allow",
    "Resource": "*"

7.    Attach the IAM policy to your EC2 instance. This enables the script to push the metrics to Amazon CloudWatch.

8.    From the CloudWatch console, set an alarm for EBSThroughoutMB. For more information, see Create a CloudWatch alarm based on a static threshold or Using Amazon CloudWatch alarms.

Be sure that you choose the correct period based on the argument that you used.