我们最近开始在我们的组织中使用Google Chat,因此我们需要从Prometheus-Alertmanager向Google聊天室发送警报。下面是我为Google chat配置的alertmanager
receiver:
- name: 'gchat-receiver'
webhook_configs:
- url: "https://chat.googleapis.com/v1/spaces/AAAArcv5Snw/messages?key=KEY&token=TOKEN"
send_resolved: false
当我们实现上面的配置时,我们的alertmanager日志中会出现以下错误:
level=error ts=2021-02-23T06:23:43.931Z caller=dispatch.go:309 component=dispatcher msg="Notify for alerts failed" num_alerts=2 err="gchat-receiver/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: https://chat.googleapis.com/v1/spaces/AAAArcv5Snw/messages?key=KEY&token=TOKEN"
level=error ts=2021-02-23T06:23:43.971Z caller=dispatch.go:309 component=dispatcher msg="Notify for alerts failed" num_alerts=1 err="gchat-receiver/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: https://chat.googleapis.com/v1/spaces/AAAArcv5Snw/messages?key=KEY&token=TOKEN"
level=error ts=2021-02-23T06:23:43.976Z caller=dispatch.go:309 component=dispatcher msg="Notify for alerts failed" num_alerts=21 err="gchat-receiver/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: https://chat.googleapis.com/v1/spaces/AAAArcv5Snw/messages?key=KEY&token=TOKEN"
level=error ts=2021-02-23T06:23:43.994Z caller=dispatch.go:309 component=dispatcher msg="Notify for alerts failed" num_alerts=2 err="gchat-receiver/webhook[0]: notify retry canceled due to unrecoverable error after 1 attempts: unexpected status code 400: https://chat.googleapis.com/v1/spaces/AAAArcv5Snw/messages?key=KEY&token=TOKEN"
在这方面的任何帮助或指导都将不胜感激。
发布于 2021-02-23 16:29:47
这是因为Google Chat希望将特定JSON有效负载模式发布到webhook地址,而默认Alertmanager payload与其不匹配,因此会得到HTTP 400
响应: bad request。
您可能需要在两者之间放置一个自定义应用程序,以便将JSON转换为Google Chat可接受的格式。Github中已经有一些repos也符合这个通用标准。(例如calert)
https://stackoverflow.com/questions/66333868
复制