I have an RDS Aurora cluster with 2 instances, a reader and a writer.
I created a CloudWatch alarm on DatabaseConnections
with dimension DBClusterIdentifier
.
But the alarm only works on one instance (the writer). The alarm will not trigger if the reader exceeds the threshold.
How do I get an alarm to trigger if any RDS instance crosses the threshold.
This is my code:
resource "aws_cloudwatch_metric_alarm" "rds-connection-count-alarm" {
alarm_name = "rds-connection-count-alarm"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "60"
statistic = "Maximum"
threshold = "1000" # max 2000 for db.r4.xlarge rds instances
dimensions {
DBClusterIdentifier = "${aws_rds_cluster.my_rds_cluster.id}"
}
alarm_description = "Alerts Slack if the DB connection count exceeds 1000"
alarm_actions = ["${data.aws_sns_topic.notification_topic.arn}"]
ok_actions = ["${data.aws_sns_topic.notification_topic.arn}"]
insufficient_data_actions = []
lifecycle {
create_before_destroy = true
}
}
I recommend using roles to monitor connections on both your writer and reader when using RDS Aurora. There are two advantages to this:
Note that if you have multiple readers the reader role is averaging them.
Cloudwatch metrics using RDS roles in AWS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With