In our previous how-to guide, we showed how to launch an EBS optimized instance in order to have higher and predictable throughput between EC2 instances and EBS volumes. Moving forward, you would need to closely monitor an EBS volume’s performance and be notified of events in time to take appropriate action.
AWS CloudWatch provides different EBS performance metrics, including:
- Volume read and write bytes
- Volume read and write operations
- Total volume read and write time
- Volume idle time
- Average queue length
- Volume throughput percentage
In this how-to guide, you will learn how to set up CloudWatch alarms and receive email notifications if EBS metrics cross a certain threshold value.
A. Identify your EBS volume
To set up an EBS cloudwatch alarm, you need to identify your EBS volume. If you are using the AWS Management Console, you can identify your instance and attached EBS volume from the EC2 console.
Clicking on volume ID will take you to the EBS volume section where you can review current EBS resource usage patterns.
Use the following command with the AWS CLI:
# aws ec2 describe-instances –instance-id <instance-id> –region <region-name>
Once you have identified your volume’s name, you can use the AWS CLI to gather more information about your EBS volume.
# aws ec2 describe-volumes –volume-id <volume-id> –region <region-name>
B. Identify a metric to set up the CloudWatch alarm
As mentioned above, there are multiple EBS metrics that you can use to set up CloudWatch alarms. First, however, you need to identify your relevant EBS metrics.
C. Create SNS Topics and Subscriptions
To send notifications to your email address, you need to create SNS topics and a subscription. To do this, go to the AWS SNS dashboard and create a topic.
Once the topic is created, copy the topic ARN and create an SNS subscription for your email ID.
Learn more about ARN
Once the subscription is created, you will receive a confirmation email. After which, you’ll have to confirm the subscription by clicking on the link. Then you will receive SNS notifications for your CloudWatch alarms.
Use the following command with the AWS CLI:
To create an SNS topic:
# aws sns create-topic –name <sns-topic-name>
Once the topic is created, you need to create a subscription using the command below:
# aws sns subscribe –topic-arn <topic-arn> –protocol email –notification-endpoint <email-address>
Confirm once you’ve received the email.
D. Create CloudWatch Alarm
To create an alarm, navigate to the CloudWatch section of the AWS Management Console, click on ‘Create Alarm‘ and select ‘EBS Metrics’.
Once the appropriate EBS metrics are selected, select your EBS volumes and associated metric for which you want to set up the alarm.
We have selected ‘VolumeQueueLength’ as our metric. According to AWS documentation, the purpose of the ‘VolumeQueueLength’ metric is to show the “total number of read and write operation requests waiting to be completed in a specified period of time.”
On the next screen, provide the name and description of your alarm along with your preferred duration, frequency, threshold value, statistics and other related information. To receive notifications, select your SNS topic from the drop down menu.
Once all of the necessary information is provided, click on ‘Create Alarm’ and your EBS alarm is all set. Whenever your EBS metric crosses the defined threshold value, it will send a notification to you.
Use the command below with the AWS CLI:
# aws cloudwatch put-metric-alarm –alarm-name <value>
[–actions-enabled | –no-actions-enabled]
Once executed, your EBS metric CloudWatch alarm will be created and a notification will be sent out whenever it crosses your defined threshold value.
To automate the process of using Amazon snapshots, N2Ws offers a solution called Cloud Protection Manager (CPM), which is an enterprise-class backup and recovery and disaster recovery solution for the EC2 compute cloud. Cloud Protection Manager is available as on a monthly subscription basis via the AWS Marketplace and allows users to manage multiple AWS accounts and configure policies and schedules to take automated snapshot backups. It also has a Windows agent to consistently back up Windows applications. Cloud Protection Manager allows you to recover a volume from a snapshot, increase its size and switch it with an existing attached volume, in a single step. To see the different editions with pricing and details, check out the pricing page on our website.