我正在尝试在我的 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
}
}
ofc 查询示例"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2"
有效
如果特定服务(如 sshd)启动与否,通过 Datadog API 或 terraform 检查的正确方法是什么?