Are you aiming to streamline your monitoring setup by integrating Prometheus alerts with your Microsoft Teams channel? You’re in the right place! This guide will walk you through the steps using a lightweight Go Web Server that receives POST messages from Prometheus Alert Manager and sends them straight to a Microsoft Teams channel via an incoming webhook URL.
Overview
This integration serves as a bridge for Prometheus alerts, which traditionally do not support direct forwarding to Microsoft Teams by default. With this project, you can quickly convert alerts to notifications that are delivered directly to your Teams channel, ensuring that your team is always informed of critical events.
Why Choose Go?
You may wonder, “Why Go?” Unlike Python, Ruby, or Node.js, Go produces a statically compiled binary. This means you don’t have to worry about dependencies, leading to a lighter and faster Docker image. If you’re a DevOps enthusiast, this efficiency is a game changer!
Getting Started (Quickstart)
Ready to dive in? Here’s how you can set this up swiftly!
Installation
There are three methods to install the integration:
- Option 1: Run using Docker
docker run -d -p 2000:2000 \
--name=promteams \
-e TEAMS_INCOMING_WEBHOOK_URL=https://outlook.office.com/webhook/xxx \
-e TEAMS_REQUEST_URI=alertmanager \
quay.io/prometheus-msteams/prometheus-msteams
./prometheus-msteams -teams-request-uri alertmanager \
-teams-incoming-webhook-url https://outlook.office.com/webhook/xxx
For detailed deployment instructions, refer to the Kubernetes Deployment Guide.
Setting up Prometheus Alert Manager
To enable alert handling, you need to configure Prometheus Alert Manager with this integration. Below is an analogy to simplify the understanding:
Think of Prometheus as a mailman and Microsoft Teams as the post office. Typically, the mailman carries alerts (letters) but cannot deliver them to the post office (Teams) directly. This integration acts as a local delivery service, facilitating the delivery of alerts to their destination.
Static URI Handler Configuration
Here’s how you can set it up:
route:
group_by: [alertname]
group_interval: 30s
repeat_interval: 30s
group_wait: 30s
receiver: prometheus-msteams
receivers:
- name: prometheus-msteams
webhook_configs:
- send_resolved: true
url: http://localhost:2000/alertmanager
Dynamic URI Handler
The dynamic webhook handler allows you to specify a webhook URL directly from the alert manager, and here is how you can structure it:
route:
group_by: [alertname]
group_interval: 30s
repeat_interval: 30s
group_wait: 30s
receiver: prometheus-msteams
receivers:
- name: prometheus-msteams
webhook_configs:
- send_resolved: true
url: http://localhost:2000/_dynamicwebhook/outlook.office.com/webhook/xxx
Simulating a Prometheus Alert to Teams Channel
To ensure everything is working smoothly, let’s simulate an alert using a JSON payload. Here’s a guide:
{
"version": "4",
"groupKey": ":alertname=high_memory_load",
"status": "firing",
"receiver": "teams_proxy",
"groupLabels": {
"alertname": "high_memory_load"
},
"commonLabels": {
"alertname": "high_memory_load",
"monitor": "master",
"severity": "warning"
},
"commonAnnotations": {
"summary": "Server High Memory usage"
},
"externalURL": "http://docker.for.mac.host.internal:9093",
"alerts": [{
"labels": {
"alertname": "high_memory_load",
"instance": "10.80.40.11:9100",
"job": "docker_nodes",
"monitor": "master",
"severity": "warning"
},
"annotations": {
"description": "10.80.40.11 reported high memory usage with 23.28%.",
"summary": "Server High Memory usage"
},
"startsAt": "2018-03-07T06:33:21.873077559-05:00",
"endsAt": "0001-01-01T00:00:00Z"
}]
}
Use the following command to send the alert:
curl -X POST -d @prom-alert.json http://localhost:2000/alertmanager
The Teams channel should receive a message confirming the alert!
Troubleshooting
If you run into any issues during setup, here are some troubleshooting tips:
- Ensure the webhook URL in the configuration is correct and accessible.
- Check your Prometheus Alert Manager logs for any delivery issues.
- Verify Docker container port mappings if using Docker.
- Test other endpoints to ensure they return expected responses.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Customizing Messages to MS Teams
The integration uses a message card template to present alerts. You can customize this template to fit your needs by creating a new file and using the Go Templating Engine. To test your designs, you can utilize the Message Card Playground.
Conclusion
By following this guide, you can achieve a seamless integration between Prometheus alerts and Microsoft Teams, enhancing your team’s monitoring capabilities.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

