Christos Michael
Christos Michael

Reputation: 1093

Send an alert notification from InfluxDb to Microsoft Teams

I am running an influxDb, on my server, and I created below:

Notification Check
Notification Endpoint (HTTP POST)
Notification Rule

All above are running successfuly

I have also created a webhook connector to Microsoft teams in order for InfluxDb send the notification alert to it.

However, for the Microsoft Teams webhook to work successfully, needs a key called "summary" inside request body of the POST request.

InfluxDb has no key called summary in their request body. Something like this:

{
    "summary":"text"
}

I am looking to find out how to alter the request body InfluxDb sends, however there is nothing on their documentation.

Any ideas ?

Upvotes: 1

Views: 1240

Answers (2)

Moha Krs
Moha Krs

Reputation: 41

This might be late but I've created my own team connection task in influxdb, where I can add mentions and buttons. Basic Example: Copy teams into a task in influxdb and add this next code at the end. This Example adds a mention for Tom Cruise with its respective teams ID ( use Graph Explorer to get the correct IDs). It's possible to add multiple mentions as follow:

mentions = addMention(name : "James Bond",id:"007") + addMention(name : "Tom Cruise",id:"123456")

Adding Button / Buttons

button = addButton(type: "Action.OpenUrl", title: "Go To Google.com", url:"google.com" )

button2 = addButton(type: "Action.OpenUrl", title: "Go To Mohameds GITHUB", url:"https://github.com/Mohamedkrs" )

url= "https://..."
endpoint1 = endpoint(url: url)
mentions = addMention(name : "James Bond",id:"007")
button = addButton(type: "Action.OpenUrl", title: "Go To Google.com", url:"google.com" )
button2 = addButton(type: "Action.OpenUrl", title: "Go To Mohameds GITHUB", url:"https://github.com/Mohamedkrs" )
crit_statuses =from(bucket: "bucket")
  |> range(start: -15s)
  |> filter(fn: (r) => r["_measurement"] == "win_cpu")
  |> endpoint1(mapFn: (r) => ({
      title: "Memory Usage",
      text: "<at>team user name</at>: ${r.host}: Process uses ${r._value} GB",
      summary: "Alert",
      mention: mentions,
      button : button + button1
    }),
  )()

Upvotes: 2

Mamatha-MSFT
Mamatha-MSFT

Reputation: 577

The incoming webhooks send messages as a card. So, the title and summary fields are mandatory. It is by design.

Upvotes: 2

Related Questions