Add custom e-mail headers (#11454)
* add custom mail headers * Aso add when sending only plain text emails * Update documentation on custom headers for filtering, and new email image
Emmanuel Vasilakis committed
Sep 14, 2021 at 13:16 UTC
4e0a3f8cda4a12c46d50bf211b6279ba8f2368cf
2 files changed
+30
-2
health/notifications/alarm-notify.sh.in
+14
@@ -2685,6 +2685,13 @@ Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
2685
MIME-Version: 1.0
2686
Content-Type: multipart/alternative; boundary="multipart-boundary"
2687
${email_thread_headers}
2688
+X-Netdata-Severity: ${status,,}
2689
+X-Netdata-Alert-Name: $name
2690
+X-Netdata-Chart: $chart
2691
+X-Netdata-Family: $family
2692
+X-Netdata-Classification: $classification
2693
+X-Netdata-Host: $host
2694
+X-Netdata-Role: $roles
2695
2696
This is a MIME-encoded multipart message
2697
@@ -3424,6 +3431,13 @@ Subject: ${html_email_subject}
3431
MIME-Version: 1.0
3432
Content-Type: multipart/alternative; boundary="multipart-boundary"
3433
${email_thread_headers}
3434
+X-Netdata-Severity: ${status,,}
3435
+X-Netdata-Alert-Name: $name
3436
+X-Netdata-Chart: $chart
3437
+X-Netdata-Family: $family
3438
+X-Netdata-Classification: $classification
3439
+X-Netdata-Host: $host
3440
+X-Netdata-Role: $roles
3441
3442
This is a MIME-encoded multipart message
3443
health/notifications/email/README.md
+16
-2
@@ -11,9 +11,9 @@ Netdata sends all emails as user `netdata`, so make sure your `sendmail` works f
11
12
email notifications look like this:
13
14
-
14
+
15
16
-## configuration
16
+## Configuration
17
18
To edit `health_alarm_notify.conf` on your system run `/etc/netdata/edit-config health_alarm_notify.conf`.
19
@@ -38,6 +38,20 @@ Where `[ROLE]` is the role you want to test. The default (if you don't give a `[
38
Note that in versions before 1.16, the plugins.d directory may be installed in a different location in certain OSs (e.g. under `/usr/lib/netdata`).
39
You can always find the location of the alarm-notify.sh script in `netdata.conf`.
40
41
+## Filtering
42
+
43
+Every notification email (both the plain text and the rich html versions) from the Netdata agent, contain a set of custom email headers that can be used for filtering using an email client. Example:
44
+
45
+```
46
+X-Netdata-Severity: warning
47
+X-Netdata-Alert-Name: inbound_packets_dropped_ratio
48
+X-Netdata-Chart: net_packets.enp2s0
49
+X-Netdata-Family: enp2s0
50
+X-Netdata-Classification: System
51
+X-Netdata-Host: winterland
52
+X-Netdata-Role: sysadmin
53
+```
54
+
55
## Simple SMTP transport configuration
56
57
If you want an alternative to `sendmail` in order to have a simple MTA configuration for sending emails and auth to an existing SMTP server, you can do the following: