Skip to content

Add the Prometheus Alertmanager UI

Description

When installing the Prometheus Alertmanager using the command,

apt install prometheus-alertmanager

The version at the time of creating this document, didn't include a user interface. The message on the default UI says,

"The Debian package of the alertmanager does not include a web application."

It also mentions that you can build and deploy the UI yourself.

In this lesson, we will run a script that builds and deploys a minimal UI.

/usr/share/prometheus/alertmanager/generate-ui.sh

The generated files will be placed into the folder /usr/share/prometheus/alertmanager/ui/

If you experience an error stating incorrect ELM version, we need to modify the elm.json file to match the version installed.

sudo nano /usr/share/gocode/src/github.com/prometheus/alertmanager/ui/app/elm.json

Change the 0.19.1 to 0.19.0

Save and exit nano.

Now run the script again

/usr/share/prometheus/alertmanager/generate-ui.sh

The generated files will be placed into the folder /usr/share/prometheus/alertmanager/ui/

If, like me, you have an iptables firewall rule blocking external access to port 9093, you won't be able to see the Alertmanager UI remotely.

So, since I already have Nginx setup, with basic auth on my Prometheus server, I will create a new location in the Nginx config specifically for the Alertmanager UI.

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

Add a new proxy_pass specific for the Alertmanager

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

Save and exit from nano

Check the Nginx config is ok

nginx -t

Restart

sudo service nginx restart
sudo service nginx status

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

Any email alerts received will contain incorrect URLs pointing to the Alertmanager.

The Alertmanager also has a defaults file, so we can indicate the external URL to use.

sudo nano /etc/default/prometheus-alertmanager

Open it and add --web.external-url and --web.route-prefix to the ARGS= variable. E.g.,

ARGS="--web.external-url=https://example.com --web.route-prefix=/"

Save, exit and check its syntax is ok.

amtool check-config /etc/prometheus/alertmanager.yml

If all is ok, then restart and check status.

sudo service prometheus-alertmanager restart
sudo service prometheus-alertmanager status

The Alertmanager URL links in any new email alerts should now be correct.

<!-- Disclaimer I am using Alertmanager 0.15.3 with Prometheus 2.15.2 on Ubuntu 20.04. The process to get a user interface for the Prometheus Alertmanager is very likely to change between different versions of the software. It could become more easy, or more difficult.

To get the versions of the Prometheus software

amtool --version
promtool --version

If you decide not to use this version that contains the UI, you can stop the service and restart the original prometheus-alertmanager again.

sudo service alertmanager stop
sudo service prometheus-alertmanager start
sudo service prometheus-alertmanager status
``` -->

## Uninstall golang-github-prometheus-alertmanager-dev

```bash
sudo apt autoremove golang-github-prometheus-alertmanager-dev
reboot

Comments