Prometheus alertmanager.yml配置出现yaml反序列化错误如何解决
Alertmanager配置反序列化报错修复方案
报错根因
两处配置结构不符合Alertmanager官方YAML规范:
- global下的http_config层级结构错误,basic_auth为http_config的子属性,用户名密码需嵌套在basic_auth下,不能直接放在global根层级
- receivers下的webhook_configs要求为数组类型,你当前直接写为对象结构,且不支持直接引用全局属性的写法
global.http_config
修复后的完整配置
global: http_config: basic_auth: username: 1234 password: 1234 inhibit_rules: - equal: - alertname - dev - instance source_match: severity: critical target_match: severity: warning receivers: - name: web.hook webhook_configs: - url: "http://localhost:8080" # 如需单独给该webhook配置不同auth可打开下方注释,无需配置则全局http_config会自动生效 # http_config: # basic_auth: # username: 1234 # password: 1234 route: group_by: - alertname group_interval: 5m group_wait: 30s receiver: web.hook repeat_interval: 1h
修改说明
- 修正了global下http_config的嵌套结构,将username、password移入
http_config.basic_auth下,符合配置规范,解决前3行类型不匹配报错 - 在webhook_configs下增加了
-将配置转为数组项,去掉了无效的全局属性引用,解决line20的类型不匹配报错 - 全局配置的http_config会自动应用到所有通知接收器,不需要在每个webhook下重复配置,如需单独为某个webhook配置不同的认证规则,再单独在对应webhook配置项中写http_config即可
内容的提问来源于stack exchange,提问作者priya jagyasi
相关产品推荐
相关产品推荐

