Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Prometheus' Alertmanager to send email through Gmail's SMTP server

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?

like image 981
duggulous Avatar asked Feb 25 '16 20:02

duggulous


People also ask

How do you use Alertmanager in Prometheus?

Prometheus triggers these alerts automatically when the expression rules match the events occurring in the Prometheus server. To configure your Alertmanager, you have to create a configuration YAML file, then use Helm to apply the configurations.


Video Answer


2 Answers

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.

like image 186
brian-brazil Avatar answered Oct 24 '22 06:10

brian-brazil


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: '[email protected]'
      from: '[email protected]'
      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.

like image 1
Vishesh Kumar Singh Avatar answered Oct 24 '22 08:10

Vishesh Kumar Singh