You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置Prometheus Alertmanager后无法接收SMTP告警邮件求助

问题分析与解决步骤

核心配置错误

你的Alertmanager配置存在两处关键语法/逻辑错误,导致SMTP告警无法触发,同时日志里的Webhook错误说明当前生效的配置可能残留了旧的Webhook设置:

1. Receiver名称不匹配

route块中的receiver字段必须指定接收器的name,而非直接填写邮箱地址。当前配置里route.receiver: myemail@gmail.com,但receivers中定义的接收器name是Mail alert,两者不匹配,Alertmanager无法找到对应的SMTP接收器,会自动 fallback到旧配置(比如之前的Webhook)。

2. Email配置项名称错误

receivers下的邮件配置项必须是**email_configs(复数形式)**,你写的email_config(单数)属于无效配置项,Alertmanager会直接忽略该设置。

修正后的完整配置

将alertmanager.yml修改为以下内容:

route:
  group_by: ['alertname']  # 建议使用标准标签(如alertname)作为分组依据,原配置的"Mail alert"并非合法标签名
  receiver: "Mail alert"   # 与receivers中定义的name保持一致

receivers:
  - name: "Mail alert"
    email_configs:  # 改为复数形式
      - to: "myemail@gmail.com"
        from: "testsmtp@gmail.com"
        smarthost: "xxxxxx:xx"
        auth_username: "testsmtp@gmail.com"
        auth_password: "xxxxxxxx"
        require_tls: true  # 显式开启TLS,适配绝大多数SMTP服务的安全要求

额外排查步骤

  • 清理残留配置:若日志仍出现Webhook的localhost连接错误,检查是否有旧配置文件在生效,启动Alertmanager时务必指定正确的配置文件:
    alertmanager --config.file=./alertmanager.yml
    
  • 验证SMTP连通性:在Alertmanager所在服务器上,用telnet或nc测试SMTP服务器的端口连通性,确认无防火墙/安全组拦截:
    telnet xxxxxx xx
    
  • 检查邮箱授权凭证:如果使用Gmail,auth_password必须是应用专用密码(开启2FA后才能生成),而非邮箱登录密码。

内容的提问来源于stack exchange,提问作者Hriday Athineni

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 10:27:47