![](/img/trans.png)
[英]How to define aws_cloudwatch_metric_alarm with multiple actions with terraform?
[英]How do I write a terraform code to create an aws_cloudwatch_metric_alarm for too many db connections?
在 AWS CloudWatch 中,我可以创建一个警报,当我的数据库有太多连接时会提醒我:
我已经使用 terraform 来创建另一个警报...
resource "aws_cloudwatch_metric_alarm" "cpu_utilization_too_high" {
alarm_name = "cpu_utilization_too_high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = var.cpu_utilization_threshold
alarm_description = "Average database CPU utilization over last 10 minutes too high"
alarm_actions = [aws_sns_topic.topic.arn]
ok_actions = [aws_sns_topic.topic.arn]
dimensions = {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
现在我想使用 terraform 创建一个警报,提醒我注意我的数据库连接,但我不知道将metric_name
设置为什么...
metric_name = ???TooMuchConnectingtoDataBase???
我查看了 terraform 文档,但它没有记录 metric_name 的用途。 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm
根据文档,
resource "aws_cloudwatch_metric_alarm" "too_many_db_connections" {
alarm_name = "too_many_db_connections"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = var.db_connection_threshold
alarm_description = "Average db connections over last 10 minutes is too high"
alarm_actions = [aws_sns_topic.topic.arn]
ok_actions = [aws_sns_topic.topic.arn]
dimensions = {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.