amazon-web-services - AWS Cloudwatch 警报 Terraform

标签 amazon-web-services terraform amazon-cloudwatch

我目前正在尝试通过 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 嵌套 block 的编写方式,您需要定义要作为警报返回的指标查询。由于未配置此功能,我收到了恰好一个错误,因为默认情况下指标查询用于多个查询。

关于amazon-web-services - AWS Cloudwatch 警报 Terraform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54792680/

相关文章:

python - 无法通过自定义 cloudformation 资源调用 lambda 函数

amazon-web-services - S3 指标的巨大差异 - Cloudwatch 与 AWS S3 CLI 与 GUI 'Get Size'

aws-api-gateway - 如何通过 Terraform 设置 aws cloudwatch 保留

Terraform:Flatcar OS 容器 Linux 配置的存储部分中的 YAML 文件渲染问题

azure - 向 azurerm 虚拟机提供文件期间连接超时

ios - 如何获取AWS SNS发送的通知记录?

Mysql 无法通过 Amazon EC2 上的套接字连接到本地服务器

node.js - DynamoDB putItem ConditionExpression 无法匹配 event.identityId

amazon-web-services - 无法删除包含错误字符的 Amazon S3 key

terraform - 非默认 VPC 的 Packer 和 Terraform 之间的循环依赖