Prometheus : Set Alert Notification (Email)2026/06/09 |
|
This is the Alert Notification Settings on Prometheus. There are many way to receive Alerts like Slack, HipChat, WeChat and others, though, on this example, Configure Alerting with Email Receiver.
For more details of Alerting, Refer to the official documents. |
|
| [1] |
For Email notification, it needs SMTP Server. |
| [2] | Install Alertmanager on Prometheus Server Host. |
|
root@dlp:~# apt -y install prometheus-alertmanager |
| [3] | Configure Prometheus Alert Settings with Email notification. |
|
root@dlp:~#
mv /etc/prometheus/alertmanager.yml /etc/prometheus/alertmanager.yml.org root@dlp:~# vi /etc/prometheus/alertmanager.yml # create new global: # SMTP server to use smtp_smarthost: 'localhost:25' # require TLS or not smtp_require_tls: false # notification sender's Email address smtp_from: 'Alertmanager <root@dlp.srv.world>' # if set SMTP Auth on SMTP server, set below, too # smtp_auth_username: 'alertmanager' # smtp_auth_password: 'password' route: # Receiver name for notification receiver: 'email-notice' # grouping definition group_by: ['alertname', 'Service', 'Stage', 'Role'] group_wait: 30s group_interval: 5m repeat_interval: 4h receivers: # any name of Receiver - name: 'email-notice' email_configs: # destination Email address - to: "root@localhost" # create new # for example, monitor node-exporter's [Up/Down]
groups:
- name: Instances
rules:
- alert: InstanceDown
expr: up == 0
for: 5m
labels:
severity: critical
annotations:
description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
summary: 'Instance {{ $labels.instance }} down'
root@dlp:~#
vi /etc/prometheus/prometheus.yml # line 17 : confirm - (Alertmanager Host):(Port) alerting: alertmanagers: - static_configs: - targets: ['localhost:9093'] # line 23 : add alert rules created above rule_files: # - "first_rules.yml" # - "second_rules.yml" - "alert_rules.yml"root@dlp:~# systemctl restart prometheus prometheus-alertmanager root@dlp:~# systemctl enable prometheus-alertmanager |
| [4] | If [node-exporter] is down, following Email is sent. (mail body is HTML) |
|
root@dlp:~# mail
? 1
Return-Path: <root@dlp.srv.world>
X-Original-To: root@localhost
Delivered-To: root@localhost
Received: from localhost (localhost [127.0.0.1])
by dlp.srv.world (Postfix) with UTF8SMTP id CCBC9602C8
for <root@localhost>; Tue, 09 Jun 2026 01:22:52 +0000 (UTC)
Subject: [FIRING:1] InstanceDown (node01.srv.world:9100 Hiroshima example critical)
To: root@localhost
From: Alertmanager <root@dlp.srv.world>
Message-Id: <1780968172838993333.8783771986990120743@dlp.srv.world>
Date: Tue, 09 Jun 2026 01:22:52 +0000
Content-Type: multipart/alternative; boundary=f9d20e9a5073ae1c30d6620dfa539d5b42fdc9dc247a809e91484b9542bf
MIME-Version: 1.0
--f9d20e9a5073ae1c30d6620dfa539d5b42fdc9dc247a809e91484b9542bf
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml" style=3D"margin: 0; font-famil=
y: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; =
font-size: 14px;">
<head>
<meta name=3D"viewport" content=3D"width=3Ddevice-width">
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8">
<title>[FIRING:1] InstanceDown (node01.srv.world:9100 Hiroshima example cri=
tical)</title>
.....
.....
|
| Sponsored Link |
|
|