【问题标题】:Alertmanager container can't send SMTP email because the connection refused from web hookAlertmanager 容器无法发送 SMTP 电子邮件,因为网络挂钩拒绝连接
【发布时间】:2021-03-25 08:12:19
【问题描述】:

我正在使用 Prometheus/Grafana/Alertmanager docker 镜像来监控我的服务。我创建了rules.yml 并将其添加到prometheus.yml 中。它工作得很好,当系统过载时我看到了 ALERTS 指标。然后这些警报被发送到alermanager,alermanager 无法将消息发送到SMTP 服务器。

显示错误

level=warn ts=2021-03-25T07:07:17.526Z caller=notify.go:674 component=dispatcher receiver=web.hook integration=webhook[0] msg="通知尝试失败,稍后重试"尝试=1 err="发布"http://127.0.0.1:5001/": 拨打 tcp 127.0.0.1:5001: 连接: 连接被拒绝"

我认为错误与 web_hook 配置有关,但我没有在 alertmanager.yml 中设置它,我使用的是 email_config。我通过创建系统服务测试了alermanager.yml,它在触发警报时向接收者发送电子邮件,所以我很确定我的配置没有错误。

这是我在alertmanager.yml中的配置

global:
  # The smarthost and SMTP sender used for mail notifications.
  smtp_smarthost: 'smtp.sendgrid.net:587'
  smtp_from: 'sample@gmail.com>'
  smtp_auth_username: 'apikey'
  smtp_auth_password: 'sample'

route:
  group_by: [alertname]
  # default receive
  receiver: default-alert
  group_wait: 30s
  group_interval: 2m
  repeat_interval: 3h
  routes:
    - match:
        alertname: PrometheusTargetMissing
      receiver: demo-alert

receivers:
- name: 'demo-alert'
  email_configs:
  - to: 'admin@gmail.com'
    # send_resolved: true
    headers: 
      Subject: "system alert"

你以前遇到过这个错误吗?我真的很感谢你的帮助。

【问题讨论】:

    标签: docker smtp alert webhooks prometheus-alertmanager


    【解决方案1】:

    已修复。这个错误是由于卷dokcer-compose文件中缺少t字符引起的

        volumes:
          - alertmanager:/***alermanager***
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-07
      • 2021-10-07
      • 2022-11-17
      • 2011-10-02
      • 1970-01-01
      • 2022-07-20
      • 2017-03-13
      • 2019-01-23
      相关资源
      最近更新 更多