How do I use CloudWatch metrics to calculate the average throughput and average number of IOPS that my EBS volume provides?

4 minute read
0

I want to use Amazon CloudWatch metrics to calculate the average throughput and number of input/output operations per second (IOPS) of my Amazon Elastic Block Store (Amazon EBS) volume.

Short description

To calculate the average throughput and number of IOPS of your volume, use math expressions with CloudWatch metrics. To monitor the data in your EBS volumes, create CloudWatch alarms.

Or, use the AWSSupport-CalculateEBSPerformanceMetrics automation document. The automation uses CloudWatch metrics to calculate aggregate throughput, number of IOPS, and the I/O size for EBS volumes. You can calculate metrics for individual EBS volumes or across all the EBS volumes that are attached to your Amazon Elastic Compute Cloud (Amazon EC2) instance.

Resolution

Manually calculate throughput

Complete the following steps:

  1. Open the CloudWatch console.
  2. Under Metrics, choose All metrics.
  3. Choose EBS namespace, and then choose Per-Volume metrics.
  4. Select the following metrics for the EBS volume:
    To calculate average IOPS, select VolumeReadOps, VolumeWriteOps, and VolumeIdleTime.
    To calculate average throughput, select VolumeReadBytes, VolumeWriteBytes, and VolumeIdleTime.
  5. Choose the Graphed metrics tab.
  6. For Statistic, choose Sum.
  7. For Period, choose the period of time that you want to view.
  8. Note the metric IDs in front of each graphed metric, such as m1, m2, m3, and so on.
  9. For Add math, choose Start with empty expression, and then enter the following expressions to calculate the expected average value.
    Calculate the average IOPS in Ops per second:
    (m1+m2)/(PERIOD(m1))
    Note: In the preceding expression, m1 is VolumeReadOps and m2 is VolumeWriteOps.
    Calculate the average throughput in bytes per second when the volume is active:
    (m1+m2)/(PERIOD(m1)-(IF(m3>59, 59, m3)))
    Note: In the preceding expression, m1 is VolumeReadBytes, m2 is VolumeWriteBytes, and m3 is VolumeIdleTime.
    Calculate the average throughput in bytes per second:
    (m1+m2)/(PERIOD(m1))
    Note: In the preceding expression, m1 is VolumeReadBytes and m2 is VolumeWriteBytes.

Throughput and IOPS are per-second measurements. So, when VolumeIdleTime is longer than 59 seconds, metric data points that are based in VolumeIdleTime X Period calculation can generate higher values than expected. Also, the average value of throughput and IOPS might differ from the actual average value because of micro-bursts. CloudWatch doesn't aggregate EBS volume metrics at the per-second interval. For more information, see How do I identify whether my Amazon EBS volume is micro-bursting and then make sure it doesn't affect performance?

Use automation to calculate throughput

Before you begin, copy the volume ID or the instance ID of the resource that you want to analyze. You must have a resource ID to run the automation document.

(Optional) Create and specify an AWS Identity and Access Management (IAM) role for the automation. If you don't choose a role, then Automation uses the permissions of the user who runs the document.

You can use the AWS Systems Manager console or AWS CLI to run the automation.

Systems Manager console

Complete the following steps:

  1. On the Systems Manager console, open the document in the AWS Region where your resources are located.
  2. In the Execute automation document section, choose Simple execution.
  3. In the Input parameters section, enter the following parameters:
    For ResourceId, enter the ID of the EBS volume or EC2 instance that you want to analyze.
    For StartTime, enter a time in the format yyyy-mm-ddThh:mm:ss and in UTC. For example, enter 2021-06-09T13:30:10.
    For EndTime, enter a time in the format yyyy-mm-ddThh:mm:ss and in UTC. For example, enter 2021-06-16T13:30:10.
    (Optional) For AutomationAssumeRole, choose your IAM role.
  4. Choose Execute.

The final output is a URL to your dashboard. To view the URL, expand the Outputs field. Use the dashboard to view the analyzed metrics and their quotas.

Note: To delete the dashboard, you must have cloudwatch:DeleteDashboards IAM permissions.

AWS CLI

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Run the start-automation-execution AWS CLI command:

aws ssm start-automation-execution --document-name "AWSSupport-CalculateEBSPerformanceMetrics" --document-version "\\$DEFAULT" --parameters '{"ResourceId":\["i-example12345"\], "StartTime":\["2021-06-09T13:30:10"\], "EndTime":\["2021-06-16T13:30:10"\], "Period":\["60"\], "AutomationAssumeRole":\[""\]}' --region us-east-1

Note: In the preceding command, replace ResourceId with the resource ID that you want to analyze. Replace StartTime and EndTime with the start and end time to view the data in CloudWatch. Replace us-east-1 with the Region for your resource. If you created an IAM role to run the automation, then replace AutomationAssumeRole with your IAM role.