alertmanager: how to send mail notification with smtp server?

Created on 10 Mar 2016  路  15Comments  路  Source: prometheus/alertmanager

Good morning friends, I need your help:
I have configured all successfuly, alertmanager takes notifications from prometheus but i would send e-mail alert notification. I have installed sendmail to test outgoing mail with my user and psw smtp and this test was successful.
Can you tell me what I have to write in alertmanager.conf (Actually my alertmanager.conf is empty) in email_configs section please?
if my smtp server is smtp.xxx.it
if my user is [email protected]
if my psw is xxx

I did not find any example about that.
Thanks in advance.

Daniele

kinquestion

Most helpful comment

You have too use the 587 port and not 465; i found this out the hard-way and it is not documented at all but the underlying Go API says it in the docs: https://golang.org/pkg/net/smtp/#SendMail

SendMail connects to the server at addr, switches to TLS if possible.

_So SSL from the start doesn't work_

global:
  # The smarthost and SMTP sender used for mail notifications.
  smtp_smarthost: 'smtp.xxx.it:587'
  smtp_from: 'Alertmanager <[email protected]>'

Next you need to set 2 environment variables containing your user / passsword

[email protected]
SMTP_AUTH_PASSWORD=xxx

We use Sendgrid with this configuration

All 15 comments

You have to configure alertmanager in alertmanager.conf.
See http://prometheus.io/docs/alerting/configuration/#email-receiver-
ro configure the mail server and
http://prometheus.io/docs/alerting/configuration/#route-route to
configure the alert routing.

Thanks for answer, in the first link I don't understand this:

The sender address.

from: I have to insert my smtp server? smtp.xxx.it?

The SMTP host through which emails are sent.

smarthost: I must necessary configure a smarthost?

is there not a simple example?
help please.
Thanks

For "from", you use anything that makes sense as a sender address for alerts.
And yes, you must configure a smarthost.

Usually, both would be set in the global section as default values for all notifications.

Example:

global:
  smtp_smarthost: localhost:25
  smtp_from: [email protected]

You have too use the 587 port and not 465; i found this out the hard-way and it is not documented at all but the underlying Go API says it in the docs: https://golang.org/pkg/net/smtp/#SendMail

SendMail connects to the server at addr, switches to TLS if possible.

_So SSL from the start doesn't work_

global:
  # The smarthost and SMTP sender used for mail notifications.
  smtp_smarthost: 'smtp.xxx.it:587'
  smtp_from: 'Alertmanager <[email protected]>'

Next you need to set 2 environment variables containing your user / passsword

[email protected]
SMTP_AUTH_PASSWORD=xxx

We use Sendgrid with this configuration

@sjoerdmulder Please have a look at https://github.com/prometheus/alertmanager/pull/266. The behavior around TLS has recently changed.

The question is also addressed in #327.
The SMTP auth behavior recently changed with #308.

most guys forget to link prometheus to alertmanager. run prometheus like so:

./prometheus -alertmanager.url http://localhost:9093
change the url according to your use.

How do I set custom subject line for email? -or insert a customized line in the body of the email..
Thanks

@Murryy79 Please open up usage questions in https://groups.google.com/forum/#!forum/prometheus-users.

The same issue here, I am using alertmanager v0.14.0 in docker container and cannot receive email notifications using AWS SES service. I had tested the SES via command line it worked fine.

The slack configuration works fine though, but it is not sending the resolved notification even though send_resolved is true.

global:
templates:

  • '/etc/alertmanager/template/*.tmpl'
    route:
    group_by: ['name']
    group_wait: 30s
    group_interval: 5m
    repeat_interval: 3h
    receiver: first-level-notifiers
    routes:
    receivers:
  • name: 'first-level-notifiers'
    email_configs:

Please advice!!

Thanks in advance :)

@unnisathyarajan did you find the solution for this? I am stuck at the same place.

@swapnilbarwat @unnisathyarajan I was able to get this to work on AWS SES using port 587

I missed this thread after my code got working. I was able to make it work using 465. Thanks for updating though.

@swapnilbarwat @unnisathyarajan @dojadop : how did you fix the issue?

I am using below setting

  • name: email-me
    email_configs:

    • to: [email protected]

      from: ABC

      smarthost: email-smtp.us-east-1.amazonaws.com:587

      auth_username: "ABC"

      auth_password: "PASSWORD"

but I am getting error

msg="failed to close SMTP connection" err="tls: use of closed connection"

Hey @vrathore18 - I ended up using AWS SES for notification. Here is my config:

receivers:
- name: 'email_receiver'
email_configs:
- send_resolved: true
to:
from:
smarthost: :25
auth_username:
auth_password:

This should work as 25 is open by default. But it looks like incompatible smtp connection in you case. Can you try telnet from your host first and then container. Connect to smtp on 587 and try sending EHLO . This should give you response if connection is successful.

btw you are on aws, then it would be good to check security group, routing table entries etc. Telnet should give you idea about this.

Was this page helpful?
0 / 5 - 0 ratings