Alertmager Prometheus

Whats about

Minimal installation of AlertManager ( default configuration file )

Systemd Unit configration

Keep all secure wit nginx

Prerequisites

Centos minimal + http://agreco.it/en/post/prometheus-installation/

dns or /etc/hosts

alert.yourdomain.TLV  IN A ip.youralertmanager.server

Donwload binary files

cd /tmp
wget https://github.com/prometheus/alertmanager/releases/download/v0.5.1/alertmanager-0.5.1.linux-amd64.tar.g

Installation

Extract the file

tar -zxvf alertmanager-0.5.1.linux-amd64.tar.gz

Move all in /opt

#estraiamo il file
tar -zxvf alertmanager-0.5.1.linux-amd64.tar.gz
mkdir /opt/prometheus/alertmanager
mv alertmanager-0.5.1.linux-amd64/* /opt/prometheus/alertmanager

Fix the permmission

chown -R prometheus:prometheus /opt/prometheus/alertmanager

Configure Systemd

Create the unit

vim /etc/systemd/system/alertmanager.service
[Unit]
Description=Prometheus AlertManager
After=network.target
After=prometheus.service
[Service]

WorkingDirectory=/opt/prometheus/alertmanager/
ExecStart=/opt/prometheus/alertmanager/alertmanager \
        -config.file=/opt/prometheus/alertmanager/simple.yml \
        -storage.path=/opt/prometheus/alertmanager/storage \
        -web.external-url=http://alert.greco.cf/alert-manager/
User=prometheus
Restart=always

[Install]
WantedBy=default.target

Reload systemd end start the unit

systemctl daemon-reload
systemctl restart alertmanager.service && systemctl status alertmanager.service
systemctl enable alertmanager.service

Create nginx configuration file

vim /etc/systemd/system/alertmanager.service
server {
    listen 80;

    server_name alert.greco.cf;

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd.users;

location / {
        proxy_pass http://127.0.0.1:9093/alert-manager/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl restart nginx

Now we can find the service at alert.greco.cf