Tutorial: Creating an Amazon CloudWatch alarm for Multi-AZ DB cluster replica lag for Amazon RDS
You can create an Amazon CloudWatch alarm that sends an Amazon SNS message when replica lag for a Multi-AZ DB cluster has
exceeded a threshold. An alarm watches the ReplicaLag
metric over a time period that you specify.
The action is a notification sent to an Amazon SNS topic or Amazon EC2 Auto Scaling policy.
To set a CloudWatch alarm for Multi-AZ DB cluster replica lag
Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the navigation pane, choose Alarms, All alarms.
-
Choose Create alarm.
-
On the Specify metric and conditions page, choose Select metric.
-
In the search box, enter the name of your Multi-AZ DB cluster and press Enter.
The following image shows the Select metric page with a Multi-AZ DB cluster named
rds-cluster
entered. -
Choose RDS, Per-Database Metrics.
-
In the search box, enter
ReplicaLag
and press Enter, then select each DB instance in the DB cluster.The following image shows the Select metric page with the DB instances selected for the ReplicaLag metric.
This alarm considers the replica lag for all three of the DB instances in the Multi-AZ DB cluster. The alarm responds when any DB instance exceeds the threshold. It uses a math expression that returns the maximum value of the three metrics. Start by sorting by metric name, and then choose all three ReplicaLag metrics.
-
From Add math, choose All functions, MAX.
-
Choose the Graphed metrics tab, and edit the details for Expression1 to
MAX([m1,m2,m3])
. -
For all three ReplicaLag metrics, change the Period to 1 minute.
-
Clear selection from all metrics except for Expression1.
The Select metric page should look similar to the following image.
-
Choose Select metric.
-
On the Specify metric and conditions page, change the label to a meaningful name, such as
ClusterReplicaLag
, and enter a number of seconds in Define the threshold value. For this tutorial, enter1200
seconds (20 minutes). You can adjust this value for your workload requirements.The Specify metric and conditions page should look similar to the following image.
-
Choose Next, and the Configure actions page appears.
-
Keep In alarm selected, choose Create new topic, and enter the topic name and a valid email address.
-
Choose Create topic, and then choose Next.
-
On the Add name and description page, enter the Alarm name and Alarm description, and then choose Next.
-
Preview the alarm that you're about to create on the Preview and create page, and then choose Create alarm.