Skip to content

Install Prometheus Alertmanager

Video Lecture

Install Prometheus Alertmanager Install Prometheus Alertmanager

Description

Install the Prometheus Alertmanager

sudo apt install prometheus-alertmanager

It has started a new service called prometheus-alertmanager

sudo service prometheus-alertmanager status

It is also managed by the user prometheus

ps -u prometheus

Note that the service is running on port 9093

Visit http://[your domain name or IP]:9093/

Block port 9093 for external requests

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

Warning

iptables settings will be lost in case of system reboot. You will need to reapply them manually,

or

install iptables-persistent

sudo apt install iptables-persistent

This will save your settings into two files called,

/etc/iptables/rules.v4

/etc/iptables/rules.v6

Any changes you make to the iptables configuration won't be auto saved to these persistent files, so if you want to update these files with any changes, then use the commands,

iptables-save > /etc/iptables/rules.v4

iptables-save > /etc/iptables/rules.v6

Check the endpoint in the prometheus.yml is correctly set for the location of your alert manager.

sudo nano /etc/prometheus/prometheus.yml

Mine is set to the alert manager running locally on localhost:9093

...

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
      - targets: ['localhost:9093']

We can optionally also add the alert manager metrics endpoint to be scraped by Prometheus as well so that we can monitor its performance.

scrape_configs:
  ...

  - job_name: alertmanager
    static_configs:
      - targets: ['localhost:9093']

If you edit the prometheus.yml, remember to check it using promtool

promtool check config /etc/prometheus/prometheus.yml

And then restart Prometheus

sudo service prometheus restart
sudo service prometheus status

Prometheus Alertmanager

Alertmanager Configuration

Prometheus 2.31 and Ubuntu 22.04 Notes

There are no considerable differences to be aware of as shown and discussed in the video in case you decide to install Prometheus 2.31.2 on Ubuntu 22.04 LTS.

Also, rather than using IPTables to manage firewall rules, you may find it easier to use the firewall options provided by your cloud provider instead.

When installing software on Ubuntu 22.04, you may see the warning "Pending kernel upgrade". Press Enter to select OK, then press TAB on the next screen then Enter to OK again. This will restart some services.

Prometheus 2.31 now allows you to build and deploy a UI for the Alertmanager. The script to build and deploy is located at /usr/share/prometheus/alertmanager/generate-ui.sh. It will place generated files in /usr/share/prometheus/alertmanager/ui/. You can use an alternate path by using the --web.ui-path option to point to a different path.

Comments