Have prometheus send alert emails in plaintext rather than HTML

I have a general desire for fewer HTML-based emails in my life :)

The prometheus documentation for configuring email alerts suggests that we can choose between text and HTML: https://prometheus.io/docs/alerting/latest/configuration/#email_config

Currently the alertmanager is configured to use the default email HTML template, which is very ugly. There is no default text-based email template so we will have to write our own. To do this, we add a custom template file that looks something like:

{{ define "email.custom.txt" }}

...

{{ end }}

and then modify our alertmanager config to reference this template:

receivers:
- name: 'email'
  email_configs:
  - to: 'receiver_mail_id@gmail.com'
    from: 'mail_id@gmail.com'
    text: '{{ template "email.custom.txt" . }}'
Assignee Loading
Time tracking Loading