Installing Prometheus Alertmanager

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Prometheus alerts allow you to issue automated notifications when certain events occur, triggered by your metric data. Alertmanager is a necessary component in this process, handling the process of sending alerts to the appropriate destination, as well as adding some additional control over alerting functionality. In this lab, you will have the opportunity to install and configure an Alertmanager instance, and connect it to an existing Prometheus server.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install Alertmanager
  1. Log in to the Prometheus server.

  2. Create a user and group for Alertmanager:

    sudo useradd -M -r -s /bin/false alertmanager
  3. Download and install the Alertmanager binaries:

    tar xvfz alertmanager-0.20.0.linux-amd64.tar.gz
    sudo cp alertmanager-0.20.0.linux-amd64/alertmanager /usr/local/bin/
    sudo chown alertmanager:alertmanager /usr/local/bin/alertmanager
    sudo mkdir -p /etc/alertmanager
    sudo cp alertmanager-0.20.0.linux-amd64/alertmanager.yml /etc/alertmanager
    sudo chown -R alertmanager:alertmanager /etc/alertmanager
    sudo mkdir -p /var/lib/alertmanager
    sudo chown alertmanager:alertmanager /var/lib/alertmanager
  4. Create a systemd unit for Alertmanager:

    sudo vi /etc/systemd/system/alertmanager.service
    Description=Prometheus Alertmanager
      --config.file /etc/alertmanager/alertmanager.yml 
      --storage.path /var/lib/alertmanager/
  5. Start and enable the alertmanager service:

    sudo systemctl enable alertmanager
    sudo systemctl start alertmanager
  6. Verify the service is running and you can reach it:

    sudo systemctl status alertmanager
    curl localhost:9093
  7. You can also access Alertmanager in a web browser at http://<PROMETHEUS_SERVER_PUBLIC_IP>:9093.

Install `amtool`
  1. Install the amtool binary:

    sudo cp alertmanager-0.20.0.linux-amd64/amtool /usr/local/bin/
  2. Create a config file for amtool:

    sudo mkdir -p /etc/amtool
    sudo vi /etc/amtool/config.yml
  3. Enter the following content in the config file:

    alertmanager.url: http://localhost:9093
  4. Verify amtool is working by pulling the current Alertmanager configuration:

    amtool config show
Configure Prometheus to Use Alertmanager
  1. Edit the Prometheus config:

    sudo vi /etc/prometheus/prometheus.yml
  2. Under alerting, add your Alertmanager as a target:

      - static_configs:
        - targets: ["localhost:9093"]
  3. Restart Prometheus to reload the configuration:

    sudo systemctl restart prometheus
  4. Verify Prometheus is able to reach the Alertmanager. Access the Prometheus Expression Browser in a web browser at http://<PROMETHEUS_SERVER_PUBLIC_IP>:9090/graph. Run the following query and ensure the current value is 1:


Additional Resources

Your company, LimeDrop, is using Prometheus for monitoring. There have been some recurring issues with a few critical services, and they would like to set up alerts so the team can act quickly when something goes wrong. In order to do this, they will need Prometheus Alertmanager.

Your task is to install and configure Alertmanager and amtool, then configure Prometheus to use Alertmanager. You can install Alertmanager directly on the provided Prometheus server, which already has Prometheus installed and running.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?