Install alerta on Centos8

Page content

AIn this post I will show you how to install alerta monitoring dashboard on Centos 8.

yum install epel-release -y
yum upgrade -y

Install and configure postgresql

In a previous post I wrote about how to Install PostgreSQL 10

sudo su - postgres
createuser alerta
createdb -O alerta alerta
ALTER USER "alerta" WITH PASSWORD 'alerta';

install python3 packages

yum install python3 python3-pip python3-setuptools python3-devel python3-psycopg2 gcc git tmux nginx

Create user for alerta and install python3 moduls with it.

useradd alerta
usermod -aG alerta nginx
su - alerta
pip3 install --user wheel alerta-server alerta uwsgi

alerta server

nano /etc/alertad.conf
DATABASE_URL = 'postgres://alerta:alerta@localhost:5432/alerta'
ALLOWED_ENVIRONMENTS=['Production', 'Development', 'Code']

We use uwsgi to create a unix socket wgere the alerta webgui can connect.

sudo mkdir -p /var/log/uwsgi
sudo chown -R alerta:alerta /var/log/uwsgi
mkdir /var/run/alerta
chown -R alerta.alerta /var/run/alerta/

echo "from alerta import app" > /usr/share/nginx/
nano /etc/uwsgi.ini
chdir = /usr/share/nginx/
mount = /
callable = app
manage-script-name = true
env = BASE_URL=/api

master = true
processes = 5
#logger = syslog:alertad
logto = /var/log/uwsgi/%n.log

socket = /var/run/alerta/uwsgi.sock
chmod-socket = 664
uid = alerta
gid = alerta
vacuum = true

die-on-term = true
nano /etc/systemd/system/uwsgi.service
Description=uWSGI service

ExecStart=/home/alerta/.local/bin/uwsgi --ini /etc/uwsgi.ini

systemctl enable uwsgi
systemctl start uwsgi
systemctl status uwsgi

alerta webgui

tar zxvf alerta-webui.tar.gz
mv dist/ /usr/share/nginx/alerta
echo '{"endpoint": "/api"}' > /usr/share/nginx/dist/config.json
nano /etc/nginx/nginx.conf
    #server {
    #    listen       80 default_server;
    #    listen       [::]:80 default_server;
    #    server_name  _;
    #    root         /usr/share/nginx/html;

    #    # Load configuration files for the default server block.
    #    include /etc/nginx/default.d/*.conf;

     #   location / {
     #   }

     #   error_page 404 /404.html;
     #       location = /40x.html {
     #   }

     #   error_page 500 502 503 504 /50x.html;
     #       location = /50x.html {
     #   }
nano /etc/nginx/conf.d/alerta.conf
server {
        listen 80 default_server;

        location /api { try_files $uri @api; }
        location @api {
            include uwsgi_params;
            uwsgi_pass unix:/var/run/alerta/uwsgi.sock;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
                root /usr/share/nginx/alerta;
nginx -t
systemctl restart nginx
systemctl enable nginx


Send testalert with alerta client.

su - alerta

echo '[DEFAULT]
endpoint = http://localhost/api' >  $HOME/.alerta.conf

echo 'export PATH=$PATH:/home/alerta/.local/bin' >> ~/.bashrc

alerta query
alerta send --resource net01 --event down --severity critical --environment Code --service Network --text 'net01 is down.'
alerta query