I would like Prometheus to send emails from a Gmail (Gapps) account when metrics cross certain thresholds. In the Alertmanager config docs, there's no mention of passwords. How do I authenticate to the SMTP server?
Asked
Active
Viewed 2.0k times
2 Answers
7
This can be done with the fields auth_username
, auth_password
and auth_identity
in the config file.
There's a full guide at http://www.robustperception.io/sending-email-with-the-alertmanager-via-gmail/
Make sure you're using a very recent alertmanager, 0.1.1 won't work.

brian-brazil
- 31,678
- 6
- 93
- 86
-
I think there must be something more required. Email notifications still fail with the error, "Must issue a STARTTLS command first" – duggulous Feb 26 '16 at 14:14
-
To further clarify for anyone reading this - at the time this question was written there was a bug in the Prometheus code that prevented Email alerts from working with TLS servers. - at the time of this comment, there is a fix committed to the github repo, but there has not been a release that includes that fix yet. At the moment, one must build Prometheus from source to use email alerts with gmail (or another SMTP host that requires TLS). – duggulous Apr 19 '16 at 22:55
-
Also note that the location of the config has changed, it's now in the config file rather than environment variable. The guide has been updated, but a release has yet to be made. – brian-brazil Apr 20 '16 at 00:00
-
@brian-brazil Is that config is still correct in 2018? – ipeacocks Jun 27 '18 at 13:53
-
1@ipeacocks, yes, just tested, this still works. I would like to `note` that it is against best practices to use environment variables for secrets, like the app password/token. @brian-brazil 's write-up will change out the variables as it writes the config. – silentpete Jul 10 '18 at 23:06
1
You can use the following template in your alert manager configuration file and change the values according to your requirement.
config:
global:
resolve_timeout: 5m
route:
group_by: ['job']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'tech-email'
routes:
- match:
alertname: Watchdog
receiver: 'null'
receivers:
- name: 'tech-email'
email_configs:
- to: 'to-email@example.com'
from: 'from-email@outlook.com'
auth_username: **********
auth_password: **********
require_tls: yes
smarthost: **********
send_resolved: true
- name: 'null'
For auth_username, auth_password and smarthost, you can generate the credentials from SES or any provider.

Vishesh Kumar Singh
- 193
- 3
- 8