[英]Create CloudWatch alarm on all instances in an RDS cluster
I have an RDS Aurora cluster with 2 instances, a reader and a writer.我有一个 RDS Aurora 集群,有 2 个实例,一个读取器和一个写入器。
I created a CloudWatch alarm on DatabaseConnections
with dimension DBClusterIdentifier
.我在DatabaseConnections
上创建了一个 CloudWatch 警报,维度为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.如果任何 RDS 实例超过阈值,如何触发警报。
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 know this is super old, but DBClusterIdentifier cannot take a regex, so unfortunately you have to have alarm per instance. 我知道这已经很老了,但是DBClusterIdentifier不能使用正则表达式,因此不幸的是您必须对每个实例发出警报。 That kinda sucks. 有点烂
For this reason, we don't use CloudWatch... we use Datadog and/or Newrelic, depending on our use case. 因此,我们不使用CloudWatch,而是根据使用情况使用Datadog和/或Newrelic。
I recommend using roles to monitor connections on both your writer and reader when using RDS Aurora.我建议在使用 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在 AWS 中使用 RDS 角色的 Cloudwatch 指标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.