Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Installing Prometheus Alertmanager

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 45m
Published
Clock icon Jun 12, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    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.

  2. Challenge

    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
      
  3. Challenge

    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
      

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans