Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
    • Security
Google Cloud Platform icon
Labs

Using Alertmanager with Prometheus

Prometheus does not just limit us to recording metrics. One of Prometheus's core functionalities is the ability to define and route alerts to any alert management endpoint we define — or, in the case of this hands-on lab, Prometheus's own sideproject, Alertmanager. Once we have our desired alerting thresholds defined, we need to set up our routes and receivers for the Alertmanager, ensuring our notifications are going to the right end user at the correct frequency and with the right information.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 21, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Add a Rules File
    1. Add a rules file configuration to the Prometheus config:

      sudo $EDITOR /etc/prometheus/prometheus.yml
      
      rule_files:
        - "rules.yml"
      
    2. Save and exit.

    3. Create and open the rules.yml file:

      sudo $EDITOR /etc/prometheus/rules.yml
      
  2. Challenge

    Add an Alert to Track Uptime
    1. Before creating the alert itself, create a recording of the desired metric:

      groups:
        - name: uptime
          rules:
            - record: job:uptime:average:ft
              expr: avg without (instance) (up{job="forethought"})
      
    2. Create an alert based on this recording:

      groups:
        - name: uptime
          rules:
            - record: job:uptime:average:ft
              expr: avg without (instance) (up{job="forethought"})
            - alert: ForethoughtApplicationDown
              expr: job:uptime:average:ft < .75
              for: 30s
              labels:
                severity: page
                team: devops
      
    3. Save and exit.

    4. Restart Prometheus:

      sudo systemctl restart prometheus
      sudo systemctl status prometheus
      
  3. Challenge

    Configure Alertmanager to Use an SMTP Smarthost
    1. Open the Alertmanager configuration file:

      sudo $EDITOR /etc/alertmanager/alertmanager.yml
      
    2. Define the global settings:

      global:
        resolve_timeout: 5m
        smtp_smarthost: 'localhost:25'
        smtp_from: 'prometheus'
      
  4. Challenge

    Set up Alertmanager Routing
    1. Set up the backup route:

      route:
        receiver: 'email_backup'
        group_by: ['alertname']
        group_wait: 10s
        group_interval: 10s
        repeat_interval: 1m
      
    2. Set up the route for critical alerts:

      route:
        receiver: 'email_backup'
        group_by: ['alertname']
        group_wait: 10s
        group_interval: 10s
        repeat_interval: 1m
        routes:
          - match:
              severity: 'critical'
            group_by: ['team']
            receiver: 'email_pager'
      
    3. Set up the route for team alerts:

      route:
        receiver: 'email_backup'
        group_by: ['alertname']
        group_wait: 10s
        group_interval: 10s
        repeat_interval: 1m
        routes:
          - match:
              severity: 'critical'
            group_by: ['team']
            receiver: 'email_pager'
            routes:
              - match:
                  team: devops
                  receiver: 'email_devops'
      ``
  5. Challenge

    Create the Needed Receivers
    1. Create the receivers:

      receivers:
      - name: 'email_backup'
        email_configs:
          - to: '[email protected]'
      - name: 'email_pager'
        email_configs:
          - to: '[email protected]'
      - name: 'email_devops'
        email_configs:
          - to: '[email protected]'
      
    2. Save and exit.

    3. Restart Alertmanager:

      sudo systemctl restart alertmanager
      
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

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.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight