Datadog新事件API迁移失败

发布于 2025-01-27 18:30:36 字数 2167 浏览 4 评论 0原文

我正在将我们的DataDog监视器之一从event Alert升级到event-v2警报以下迁移指南。我们的监视器是使用Datadog Terraform提供商创建的。

当前监视器使用事件警报类型:

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警报类型的迁移监视器:

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" {

感谢是否有人可以帮助弄清楚这里的问题。

I'm upgrading one of our datadog monitors from event alert to event-v2 alert following this migration guide. Our monitors are created using Datadog Terraform provider.

Current monitor using event alert type:

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
}

This monitor works as expected and Datadog alerts get triggered once AWS GuardDuty incident is detected.

Migrated monitor using event-v2 alert type:

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
}

However, this gives an error when performing a terraform plan saying that the request has been rejected by DataDog due to invalid query format.

$ 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" {

Appreciate if anyone could help with figuring out what's wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长发绾君心 2025-02-03 18:30:36

我发现了同样的问题,似乎新类型event-v2警报不再支持query param中的单个引号。我们需要到处使用双重报价(另外需要逃脱)。

示例:“ events(\”源:Amazon_SNS \“)。汇总(\“ count \”)。last(\“ xm \”)&gt; 0“”

好奇地,支持迁移doc doc do do dion'提到这种破裂的变化。

I found the same issue and it seems that the new type event-v2 alert doesn't support single quotes in the query param anymore. We need to use double quotes everywhere (plus need to escape them).

Example: "events(\"sources:amazon_sns\").rollup(\"count\").last(\"xm\") > 0"

Curiously, the support migration doc doesn't mention this breaking change.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文