Alert Manager for Prometheus (AWS EC2)
Configure Alert Manager:
Step1: Download the latest Alert manager package.
wget https://github.com/prometheus/alertmanager/releases/download/v0.16.2/alertmanager-0.16.2.linux-amd64.tar.gz
unpack it: tar -xvzf alertmanager-0.16.2.linux-amd64.tar.gz
Move binary to /usr/local/bin/ folder
sudo su
mv alertmanager-0.16.2.linux-amd64/alertmanager /usr/local/bin/
Step 2: Create an Alert manager user to run the Alert manager service.
sudo vi /etc/systemd/system/alertmanager.service
[Unit]
Description=AlertManager Server Service
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=Simple
ExecStart=/usr/local/bin/alertmanager \
--config.file /etc/alertmanager/alertmanager.yml
[Install]
WantedBy=multi-user.target
Step 3: Log in to the Prometheus server and open the prometheus.yml file.
vi /etc/prometheus/prometheus.yml
configure alertmanager and rules file .
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- 'Serverip:9093'
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "alert_rules.yml"
Step 4: Create Rule file on that basic we will get notification
sudo vi /etc/prometheus/alert_rules.yml
add below code into the file :
groups:
- name: example
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
Step 5: Create required directly and move alertmanager.yml file
sudo mkdir /etc/alertmanager
sudo mv alertmanager-0.16.2.linux-amd64/alertmanager.yml /etc/alertmanager/
vi /etc/alertmanager/alertmanager.yml
edit the code as per below :
global:
resolve_timeout: 1m
route:
group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h
receiver: 'email_me'
receivers:
- name: 'email_me'
email_configs:
- to: kanchanawsdemo@gmail@gmail.com
from: kanchanawsdemo@gmail.com
smarthost: smtp.gmail.com:587
auth_username: kanchanawsdemo@gmail.com
auth_identity: kanchanawsdemo@gmail.com
auth_password: asgbshrptryplekm
send_resolved: true
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
Step 6: Reload the daemon and start the alertmanager service
sudo systemctl daemon-reload
sudo systemctl start alertmanager
sudo systemctl status alertmanager
sudo systemctl restart prometheus
sudo systemctl status prometheus
sudo systemctl start node_exporter
sudo systemctl stop node_exporter
sudo systemctl status node_exporter
Learn about What is Prometheus? and How does it work?
---
Thanks & Regards,
Kanchan Soni
(A girl who saw the dream with an open eye to compete with self capability in the area of IT and its Next-Gen Technology, with the ability to complete the task with perfection.)
Email: kanchansoni.cse@gmail.com
Comments
Post a Comment