Hi, I’m trying to send alert notification via email and unfortunatly it failes. I have grafana and SMTP servers running in docker containers. Docker-compose looks like this:
version: '3.9'
services:
grafana:
image: grafana/grafana-oss:8.2.6
ports:
- 3000:3000
environment:
- GF_ALERTING_ENABLED=false #disable dashboard alerting
- GF_UNIFIED_ALERTING_ENABLED=true #enable alerting independent from dashboards
- GF_SMTP_ENABLED=true
- GF_SMTP_HOST=localhost:587
- GF_SMTP_SKIP_VERIFY=true
volumes:
- grafana-storage:/var/lib/grafana
smtp:
image: namshi/smtp
ports:
- 587:587
environment:
- PORT=587
When I test contact point from the browser I get an info:
Failed to send test alert.: Failed to send notification to email addresses: test@myCompany.com: dial tcp 127.0.0.1:587: connect: connection refused
And in the terminal appears this:
grafana_1 | t=2022-05-04T08:51:56+0000 lvl=info msg="level=error msg=\"Missing receiver\"" logger=alerting.notifier.email
grafana_1 | t=2022-05-04T08:51:56+0000 lvl=info msg="level=error msg=\"Missing group labels\"" logger=alerting.notifier.email
grafana_1 | t=2022-05-04T08:51:56+0000 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/alertmanager/grafana/config/api/v1/receivers/test status=207 remote_addr=192.168.1.22 time_ms=15 size=306 referer="http://localhost:8080/alerting/notifications/receivers/test-smtp/edit?alertmanager=grafana"
When my alert fires, in terminal I get:
grafana_1 | t=2022-05-04T08:50:05+0000 lvl=info msg="level=debug component=dispatcher msg=\"Received alert\" alert=alert1[17308dc][active]" logger=alertmanager org=1
grafana_1 | t=2022-05-04T08:50:05+0000 lvl=info msg="level=debug component=dispatcher aggrGroup=\"{}/{myAlert=\\\"testAlert\\\"}:{}\" msg=flushing alerts=[alert1[17308dc][active]]" logger=alertmanager org=1
grafana_1 | t=2022-05-04T08:50:05+0000 lvl=info msg="level=error component=dispatcher msg=\"Notify for alerts failed\" num_alerts=1 err=\"test-receiver/email[0]: notify retry canceled due to unrecoverable error after 1 attempts: Failed to send notification to email addresses: test@myCompany.com: dial tcp 127.0.0.1:587: connect: connection refused\"" logger=alertmanager org=1
grafana_1 | t=2022-05-04T08:45:38+0000 lvl=info msg="level=error msg=\"Missing receiver\"" logger=alerting.notifier.email
grafana_1 | t=2022-05-04T08:45:38+0000 lvl=info msg="level=error msg=\"Missing group labels\"" logger=alerting.notifier.email
grafana_1 | t=2022-05-04T08:45:38+0000 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/alertmanager/grafana/config/api/v1/receivers/test status=207 remote_addr=192.168.1.22 time_ms=15 size=302 referer="http://localhost:8080/alerting/notifications/receivers/test-receiver/edit?alertmanager=grafana"