【问题标题】:Datadog monitor API/terraform process monitor checkDatadog 监视器 API/terraform 进程监视器检查
【发布时间】:2017-07-21 04:33:14
【问题描述】:

我正在尝试在我的 terraform 代码库中集成对 sshd 进程的 Datadog 监视器检查,但我收到了 datadog_monitor.host_is_up2: error updating monitor: API error 400 Bad Request: {"errors":["The value provided for parameter 'query' is invalid"]}

我所做的是复制我在 Datadog 面板上创建的监视器查询并将其粘贴到 tf 文件中:

resource "datadog_monitor" "host_is_up2" {
  name = "host is up"
  type = "metric alert"
  message = "Monitor triggered"
  escalation_message = "Escalation message"

  query = "process.up.over('process:ssh').last(4).count_by_status()"

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

  notify_no_data = false
  renotify_interval = 60

  notify_audit = false
  timeout_h = 60
  include_tags = true
  silenced {
    "*" = 0
  }
}

查询示例 "avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2" 有效

通过 Datadog API 或 terraform 检查特定服务(如 sshd)是否启动的正确方法是什么?

【问题讨论】:

  • Datadog登录后有在线聊天窗口,一般可以直接得到答复。这将是您的问题的第一次联系。如果问题得到解决,请在此处更新。

标签: api monitor terraform datadog


【解决方案1】:

您的代码中有两个错误:

  1. 使用的type 是错误的。应该是 service check 而不是 metric alert
  2. 您需要将process.up 括在一对'' 中。

完成后,您的代码将完美运行。

【讨论】:

  • 刚刚在我这边测试过,确认是正确的。如果您将 \" 转义为 \",您也可以使用 " 引号
猜你喜欢
  • 1970-01-01
  • 2022-11-09
  • 2010-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-18
相关资源
最近更新 更多