Skip to content

Contains an example on how you can use your own email template for Prometheus Alertmanager.

Notifications You must be signed in to change notification settings

sichvoge/alertmanager-custom-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Using custom email templates

Contains an example on how you configure your own email template for Prometheus' Alertmanager in OpenShift.

Add email template to the Alertmanager Secret

  1. Open Alertmanager Secret:
$ kubectl -n openshift-monitoring edit secret alertmanager-main
  1. Change secret and add the myemailtemplate.tmpl key and specify the content of your template as a base64 encoded string (find an example for a typical email template in the myemailtemplate.tmpl file in this repository).
apiVersion: v1
kind: Secret
metadata:
  name: alertmanager-main
  namespace: openshift-monitoring
type: Opaque
data:
  alertmanager.yaml: {BASE64_CONFIG}
  myemailtemplate.tmpl: {BASE64_TEMPLATE}

Configure Alertmanager

  1. Print the currently active Alertmanager configuration into file alertmanager.yaml:
$ kubectl -n openshift-monitoring get secret alertmanager-main --template='{{ index .data "alertmanager.yaml" }}' | base64 -d > alertmanager.yaml
  1. Change the configuration in file alertmanager.yaml to your new configuration:
data:
 config.yaml: |
  global:
    resolve_timeout: 5m
  route:
    group_wait: 30s
    group_interval: 5m
    repeat_interval: 12h
    receiver: default
    routes:
    - match:
        alertname: Watchdog
      repeat_interval: 5m
      receiver: watchdog
  receivers:
  - name: default
  - name: watchdog
  - name: myemail
    email_configs:
    - send_resolved: true
      to: '[email protected]'
      html: '{{ template "email.mytemplate.html" . }}'
  templates:
  - 'myemailtemplate.tmpl'
  1. Apply the new configuration in the file:
$ kubectl -n openshift-monitoring create secret generic alertmanager-main --from-file=alertmanager.yaml --dry-run -o=yaml |  oc -n openshift-monitoring replace secret --filename=-

About

Contains an example on how you can use your own email template for Prometheus Alertmanager.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published