Sending MongoDB Alerts to Microsoft Teams

· 3min · Dan F.
Table of Contents

Recently, I discovered that MongoDB Atlas and Mongo Ops Manager do not have the ability to send alerts directly to Microsoft Teams. Since I've been using rust more frequently, I decided to create a small web service that receives MongoDB alerts, and transforms them into compatible Microsoft Teams Cards, before posting them to a specified Teams incoming webhook.

You can browse the git repo here. I am definitely no rust expert, so I welcome pull requests or issues.


The executable listens on the following paths when running, for proper json posts:

    This will return the json back to the user, good for debugging
    This will save the posted body to stdout within the container
    This will receive posted alerts and transform them before sending them to the Microsoft Teams webhook
    This will receive posted alerts, and return the transformed card back to the client
    Prints ok if server is healthy
    Shows the current configuration of endpoints


The two primary ways to utilize mongo_alerts_2teams are either through a docker container, or through a compiled binary.

First, you will need to create a config.yml file, which will contain your endpoints, and Teams urls. Create a file named config_example.yml following this format:

  url: ""

  url: ""

To start the docker container:

docker run -d -p 8000:8000  -v $(pwd)/config_example.yml:/app/config_example.yml findelabs/mongo_alerts_2teams:latest --config /app/config_example.yml

When, compiling from source. First make sure you have rust installed:

cargo install --git

Once you have either a running container or binary, you can add the link to either Atlas or Mongo Ops Manager as a webhook for alerts. This link should look something like http://myserver:8000/alert.


You can use this test alert to see if you container or binary is working properly. First go ahead and start up mongo_alerts_2teams on port 8000. Then post this body to http://localhost:8000/testalert:

curl -s http://localhost:8000/testalert -d "{

This should return a json doc like the one below, which is the MongoDB alert transformed into a card that Teams recognizes:

  "@context": "",
  "@type": "MessageCard",
  "sections": [
      "activityImage": "",
      "activitySubtitle": null,
      "activityTitle": "Replica set elected a new primary",
      "facts": [
          "name": "Replicaset",
          "value": "\"replicaset_name\""
          "name": "Server",
          "value": "\"localhost:27017\""
          "name": "Type",
          "value": "\"REPLICA_SET\""
  "summary": "MongoDB Alert Card",
  "themeColor": "12924F",
  "title": "Alert Closed"

Has been tested on Ubuntu, MongoDB Atlas, and Ops Manager 4.4.1