alertmanaget邮箱告警报错记录

背景

k8s集群需要上监控,整体架构为内网环境,prometheus和grafana已经部署完成,需要配置告警,客户测有内网的邮件服务器,邮件服务连接如图:

20250825104626

报错

alertmanager配置如下:
20250825104639
根据客户提供的邮件服务器内容填写配置,但是报错如下:

ts=2024-12-16T10:26:32.660Z caller=notify.level=warn component=dispatcher receiver=email integration=email[0] aggrGroup="{}:{alertname=\"ECS_CPU使用率\"}" msg="Notify attempt failed, will retry later" attempts=1 err="*smtp.plainAuth auth: unencrypted connection"
# 返回不支持未加密连接

# 随后我又将smtp_require_tls设置为 true,报错如下:
ts=2024-12-16T10:32:32.663Z caller=notify.level=warn component=dispatcher receiver=email integration=email[0] aggrGroup="{}:{alertname=\"ECS_CPU使用率\"}" msg="Notify attempt failed, will retry later" attempts=1 err="'require_tls' is true (default) but \"18802.aid.smtp.easeye.com.cn:27\" does not advertise the STARTTLS extension"
# 返回自建的邮件服务器27端口不支持STARTTLS 扩展

解决

和客户沟通之后,客户明确表明他用python调用返回正常,而我用prometheus却不行,prometheus是go语言开发的,随后在go的官网看到:
20250825104730

意思为:用go的时候只能连接本地的smtp,想要使用其他机器的smtp需要使用加密连接的方式。但是客户的邮件服务器并设置没有加密的功能,最后在alertmanager的pod里面新增了一个haproxy容器,haproxy监听25端口,代理到内网的邮件服务器,alertmanager的邮箱地址填写127.0.0.1:25,由于同一个pod里面的所有容器共享网络,这样alertmanager等同于用不加密的方式连接本地的smtp,最后告警邮件发送成功。

posted @ 2025-07-31 22:58  阿峰博客站  阅读(21)  评论(0)    收藏  举报