Skip to content

Instantly share code, notes, and snippets.

@karthikeayan
Created May 13, 2020 12:53
Show Gist options
  • Save karthikeayan/a2483f224f269c8dbc44c0d449a40ee6 to your computer and use it in GitHub Desktop.
Save karthikeayan/a2483f224f269c8dbc44c0d449a40ee6 to your computer and use it in GitHub Desktop.

Send E-Mail from alertmanager by using AWS SES as SMTP server

Alertmanager can be configured to send notifications to different targets, Slack, Email, PagerDuty etc.

Use the below steps to configure AWS SES as SMTP server to send E-Mails from alertmanager

  • The from address should be already verified in AWS SES to send E-Mails from that address

  • Check and confirm if you have secret named "alertmanager-main" in monitoring namespace

  • Create a file called alertmanager.yaml with below contents, modify as needed

"global": 
  "resolve_timeout": "5m"
"receivers": 
- "name": "org-prometheus-notify"
  "email_configs":
  - "to": "ksundararajan@organization.com"
    "from": "noreply@organization.com"
    "smarthost": "email-smtp.us-east-1.amazonaws.com:587"
    # The catch here is aws access key and secret won't work here, we should create SMTP credentials from AWS Console
    "auth_username": "<SMTP_USERNAME>"
    "auth_password": "<SMTP_PASSWORD>"
    "require_tls": true
"route": 
  "group_by": 
  - "job"
  "group_interval": "5m"
  "group_wait": "30s"
  "receiver": "org-prometheus-notify"
  "repeat_interval": "12h"
  "routes": 
  - "match": 
      "alertname": "Watchdog"
    "receiver": "org-prometheus-notify"
  • Create alertmanager-secret-k8s.yaml with below contents
apiVersion: v1
data:
  alertmanager.yaml: ALERTMANAGER_CONFIG
kind: Secret
metadata:
  name: alertmanager-main
  namespace: monitoring
type: Opaque
  • Execute the below command to update the secret by using the contents in alertmanager.yaml
sed "s/ALERTMANAGER_CONFIG/$(cat alertmanager.yaml | base64 -w0)/g" alertmanager-secret-k8s.yaml | kubectl apply -f -
  • Alertmanager pods will reload the configuration change by itself and should start sending E-Mails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment