【问题标题】:AWS Cloudwatch Alert TerraformAWS Cloudwatch 警报 Terraform
【发布时间】:2019-07-14 12:24:36
【问题描述】:

我目前正在尝试通过 Terraform 推出 AWS cloudwatch 指标警报,但遇到以下错误。

Error applying plan:

1 error(s) occurred:

* aws_cloudwatch_metric_alarm.alarm_name: 1 error(s) occurred:

* aws_cloudwatch_metric_alarm.alarm_name: Creating metric alarm failed: ValidationError: Exactly one element of the metrics list should return data.
    status code: 400, request id: xxxxxxxx-xxxxxxx-xxxxxx\n\nTerraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure."

这是 Terraform 代码:​​

resource "aws_cloudwatch_metric_alarm" "elb_monitor" {
  alarm_name                = "openam-elb-monitor"
  comparison_operator       = "GreaterThanOrEqualToThreshold"
  evaluation_periods        = "2"
  threshold                 = "1"
  alarm_description         = "UnHealthyHostCount for openam elbs"
  insufficient_data_actions = []
  metric_query {
      id = "elb_unhealthy_host_count"
      metric {
          metric_name = "UnHealthyHostCount"
          namespace   = "AWS/ELB"
          period      = "120"
          stat        = "Maximum"
          unit        = "Count"
          dimensions  = {
              LoadBalancerName = "development_lb"
          }
      }
    }
}

关于为什么会发生这种情况的任何想法?

【问题讨论】:

  • 您的 metric_query 似乎返回了多个指标。
  • 没错,而且在使用metric_query块的时候还需要定义将哪个查询设置为警报,它不能带列表
  • 如果将我的评论标记为有用,我将不胜感激

标签: amazon-web-services terraform amazon-cloudwatch


【解决方案1】:

原来这是我的配置。 metric_query 嵌套块的编写方式,您需要定义您希望作为警报返回的指标查询。因为这没有配置,所以我收到了exactly one error,因为默认情况下度量查询用于多个查询。

【讨论】:

猜你喜欢
  • 2021-05-25
  • 2021-10-30
  • 2020-03-11
  • 1970-01-01
  • 2019-08-01
  • 1970-01-01
  • 2023-03-06
  • 2021-10-19
  • 2015-10-12
相关资源
最近更新 更多