部署prometheus-msteams时遇YAML反序列化错误求助
解决prometheus-msteams部署时YAML反序列化报错问题
报错信息
{"caller":"main.go:174","err":"yaml: unmarshal errors:\n line 1: cannot unmarshal !!seq into main.PromTeamsConfig","ts":"2022-10-12T18:24:37.97854431Z"}
问题原因
这个错误的核心是:你的prometheus-msteams配置文件最外层用了列表(数组)格式(以-开头),但程序期望的是对象格式(键值对结构),导致YAML反序列化失败。
解决方案
单Teams通道场景
检查配置文件,确保最外层是键值对对象,而非列表:
错误示例(列表格式,会报错):
- alertmanager_url: "http://alertmanager:9093" teams_webhook_url: "https://outlook.office.com/webhook/xxx"
正确示例(对象格式):
alertmanager_url: "http://alertmanager:9093" teams_webhook_url: "https://outlook.office.com/webhook/xxx"
多Teams通道路由场景
如果需要按规则将告警发送到不同Teams通道,需用routes字段包裹列表,最外层仍保持对象结构:
alertmanager_url: "http://alertmanager:9093" routes: - match: severity: critical teams_webhook_url: "https://outlook.office.com/webhook/critical-channel" - match: severity: warning teams_webhook_url: "https://outlook.office.com/webhook/warning-channel"
修正配置后,重启prometheus-msteams服务即可解决该问题。
内容的提问来源于stack exchange,提问作者Marudsa Cifuentes
相关产品推荐
相关产品推荐

