【问题标题】:DataDog new Events API migration failsDataDog 新事件 API 迁移失败
【发布时间】:2022-06-22 00:43:22
【问题描述】:

我正在按照this 迁移指南将我们的一个数据狗监视器从event alert 升级到event-v2 alert。我们的监视器是使用 Datadog Terraform 提供程序创建的。

当前监视器使用event alert 类型:

resource "datadog_monitor" "guardduty_high_severity_findings" {
  name = "[tf] [${terraform.workspace}] AWS Guardduty Reporting High Severity Findings"
  type = "event alert"

  message = <<EOT
Some custom message
EOT

  escalation_message = <<EOT
<nil>
EOT

  tags              = ["system:ops", "service:aws"]
  query             = "events('sources:sns priority:all').rollup('count').last('xm') > 0"
  notify_no_data    = false
  no_data_timeframe = 0
  renotify_interval = 0
  notify_audit      = false
  timeout_h         = 0
  include_tags      = true
}

此监视器按预期工作,一旦检测到 AWS GuardDuty 事件,就会触发 Datadog 警报。

使用 event-v2 alert 类型迁移的监视器:

resource "datadog_monitor" "guardduty_high_severity_findings" {
  name = "[tf] [${terraform.workspace}] AWS Guardduty Reporting High Severity Findings"
  type = "event-v2 alert"

  message = <<EOT
Some custom message
EOT

  escalation_message = <<EOT
<nil>
EOT

  tags              = ["system:ops", "service:aws"]
  query             = "events('sources:amazon_sns').rollup('count').last('xm') > 0"
  notify_no_data    = false
  no_data_timeframe = 0
  renotify_interval = 0
  notify_audit      = false
  timeout_h         = 0
  include_tags      = true
}

但是,这会在执行 terraform 计划时出错,指出请求已被 DataDog 拒绝,因为查询格式无效。

$ terraform plan
...
Error: error validating monitor from https://api.datadoghq.com/api/v1/monitor/validate: 400 Bad Request: {"errors": ["The value provided for parameter 'query' is invalid: invalid operator specified: "]}

  with datadog_monitor.guardduty_high_severity_findings,
  on monitors-static.tf line 106, in resource "datadog_monitor" "guardduty_high_severity_findings":
 106: resource "datadog_monitor" "guardduty_high_severity_findings" {

感谢是否有人可以帮助找出这里出了什么问题。

【问题讨论】:

    标签: terraform datadog terraform-provider


    【解决方案1】:

    我发现了同样的问题,似乎新类型 event-v2 alert 不再支持 query 参数中的单引号。我们需要在任何地方使用双引号(加上需要转义它们)。

    示例:"events(\"sources:amazon_sns\").rollup(\"count\").last(\"xm\") &gt; 0"

    奇怪的是,支持迁移文档没有提到这个重大变化。

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 2016-02-16
      • 2018-08-27
      • 2020-05-29
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多