Terraform Datadog 查询无效

Terraform Datadog Query Is Invalid

我正在尝试为 google pub sub 创建监视器,但收到“无效查询”错误。这是我查看另一个工作监视器的源代码时的查询文本,所以我很困惑为什么这不起作用。

错误:Error: error creating monitor: 400 Bad Request: {"errors":["The value provided for parameter 'query' is invalid"]}

地形:

resource "datadog_monitor" "bad_stuff_sub_monitor" {
  name               = "${var.customer_name} Bad Stuff Monitor"
  type               = "metric alert"
  message            = "${var.customer_name} Bad Stuff Topic getting too big. Notify: ${var.datadog_monitor_notify_list}"
  escalation_message = "Escalation message @pagerduty"

  query = "avg:gcp.pubsub.subscription.num_undelivered_messages{project_id:terraform_gcp_test}"

  thresholds = {
    ok                = 0
    warning           = 1
    warning_recovery  = 0
    critical          = 2
    critical_recovery = 1
  }

  notify_no_data    = false
  renotify_interval = 1440

  notify_audit = false
  timeout_h    = 60
  include_tags = true

  # ignore any changes in silenced value; using silenced is deprecated in favor of downtimes
  lifecycle {
    ignore_changes = [silenced]
  }

  tags = [var.customer_name, var.project_name]
}

所以我最后只是查看了 datadog terraform 提供程序中的测试,并注意到它们正在测试的查询格式。

  query = "avg(last_30m):avg:gcp.pubsub.subscription.num_undelivered_messages{project_id:${var.project_name},subscription_id:{project_id:terraform_gcp_test} > 2"

您似乎需要指定一个时间范围,并添加一个与您的严重警报阈值相匹配的比较阈值。那就是缺少的东西。