avatarMirco on Tech

Summary

This tutorial explains how to integrate Microsoft Teams with the Alertmanager to receive notifications and reduce incident response time.

Abstract

This tutorial is a bonus part of the Monitoring Stack Series and demonstrates how to add Microsoft Teams to the monitoring stack. It explains how to configure Microsoft Teams, add prom2teams to the stack, update alerts, and configure the Alertmanager. The tutorial also provides a handy tool to check the configuration using the routing tree editor. The result is that users will receive a notification from Teams for critical alerts and an email for non-critical alerts.

Bullet points

  • This tutorial is a bonus part of the Monitoring Stack Series.
  • Many companies use Microsoft Teams, and receiving alerts in Teams allows for faster incident response.
  • The Alertmanager does not support Teams out of the box, so users must use Webhooks to achieve this.
  • prom2teams is used to send messages to Teams.
  • Users must add prom2teams to their docker-compose.yml.
  • The Alertmanager uses labels to decide which alert goes to which notification channel.
  • The Alertmanager sends alerts with medium severity to Teams and repeats this every four hours until the issue is fixed.
  • A handy tool to check the configuration is the routing tree editor.
  • Users will receive a notification from Teams for critical alerts and an email for non-critical alerts.

How Alertmanager and Teams easily reduce incident response time proactive

Get notifications from the Alertmanager to Microsoft Teams

This tutorial is a bonus part of the Monitoring Stack Series.

Many companies use Microsoft Teams. Receiving alerts in Teams allows you to react faster. It makes working on an incident visible, as you can answer the message. Let’s add it to our monitoring stack!

As always, head over to GitHub to get the full code.

Configure Microsoft Teams

Add a new channel in Teams

Alertmanager does not support Teams out of the box. You must use Webhooks to achieve this. The Webhook is used by prom2teams to write messages.

Add a channel to the team which should receive the notifications if you do not have one. Click on the dots beside the team name and choose Add Channel.

To add a Webhook, click on the dots beside the channel and click on Connectors .

Add a Webhook

Configure an Incoming Webhook. Teams shows the Webhook URL once you click Create. Copy this URL in the next step.

Configure a Webhook

Add prom2teams to the stack

prom2teams uses the webhook to send messages to Teams.

Add prom2teams to your docker-compose.yml :

Update your alerts

The Alertmanager uses labels to decide which alert goes to which notification channel. Change the prometheus/alerts.yml to contain the following:

Now you have two alerts with different labels.

Configure the Alertmanager

Change alertmanager/alertmanager.yml so that the Alertmanager is aware of prom2teams:

Now, the Alertmanager can publish to two channels. matchers define which channel to use.

The Alertmanager sends alerts with medium severity to Teams. This is repeated every four hours — until you fix it!

A handy tool to check your configuration is the routing tree editor. Add labels and values of your alert to see which route they will take.

Check the result

Start the stack with docker-compose up and wait until the alerts fire.

You will get a notification from Teams for the InstanceDownCritical alert:

And an email for the InstanceDown alert:

Which notification channels do you want to see next? Leave me a message!

Docker
Monitoring
Prometheus
Microsoft Teams
Site Reliability
Recommended from ReadMedium