我正在尝试使用 terraform 在 Cloudwatch 中设置和警报。我的告警基本上需要检查网关在1分钟的2个时段内是否有超过5%的5xx错误。
我已经尝试了以下代码,但它不起作用:
resource "aws_cloudwatch_metric_alarm" "gateway_error_rate" {
alarm_name = "gateway-errors"
comparison_operator = "GreaterThanOrEqualToThreshold"
alarm_description = "Gateway error rate has exceeded 5%"
treat_missing_data = "notBreaching"
metric_name = "5XXError"
namespace = "AWS/ApiGateway"
period = 60
evaluation_periods = 2
threshold = 5
statistic = "Average"
unit = "Percent"
dimensions = {
ApiName = "my-api"
Stage = "dev"
}
}
即使部署了警报,也不会显示数据。做一些测试,我注意到这个警报显然不接受单位“百分比”。
有没有人有关于如何配置此类警报的示例terraform
?cloudformation