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:

    wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertmanager-0.20.0.linux-amd64.tar.gz
    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
    [Unit]
    Description=Prometheus Alertmanager
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=alertmanager
    Group=alertmanager
    Type=simple
    ExecStart=/usr/local/bin/alertmanager 
      --config.file /etc/alertmanager/alertmanager.yml 
      --storage.path /var/lib/alertmanager/
    
    [Install]
    WantedBy=multi-user.target
  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:

    alerting:
      alertmanagers:
      - 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:

    prometheus_notifications_alertmanagers_discovered

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

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