Install Prometheus Alert Manager

Video Lecture

Install Prometheus Alert Manager Install Prometheus Alert Manager

Description

Download the latest Prometheus Alert Manager binary from https://prometheus.io/download/#alertmanager

wget https://github.com/prometheus/alertmanager/releases/download/v0.19.0/alertmanager-0.19.0.linux-amd64.tar.gz
tar xvfz alertmanager-0.19.0.linux-amd64.tar.gz

CD into the new alertmanager-0.19.0.linux-amd64 folder

cd alertmanager-0.19.0.linux-amd64
ls -lh

Try and run it,

./alertmanager --config.file=alertmanager.yml

Note that it's running on port 9093

Stop the running process, and copy the new files to bin folder.

cp -r . /usr/local/bin/alertmanager

Create a file called alertmanager.service

sudo nano /etc/systemd/system/alertmanager.service

Add the script and save

[Unit]
Description=Prometheus Alert Manager Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/alertmanager/alertmanager \
        --config.file=/usr/local/bin/alertmanager/alertmanager.yml \
        --web.external-url=https://[your domain name]/alertmanager \
        --web.route-prefix=/

[Install]
WantedBy=multi-user.target

Now start and check the service is running.

sudo service alertmanager start
sudo service alertmanager status

We can now leave the new Prometheus Alert Manager service running. If you ever need to stop the new Prometheus Alert Manager service, then type

sudo service alertmanager stop
sudo service alertmanager status

Try http://[your domain name]:9093/

Block Port 9093

iptables -A INPUT -p tcp -s localhost --dport 9093 -j ACCEPT
iptables -A INPUT -p tcp --dport 9093 -j DROP
iptables -L

Edit Nginx prometheus config

sudo nano /etc/nginx/sites-enabled/prometheus

add to nginx

    location /alertmanager/ {
        proxy_pass           http://localhost:9093/;
    }

Restart nginx

sudo service nginx restart
sudo service nginx status

Now visit http://[your domain name]/alertmanager