'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 ?
Solution 1:[1]
The incoming webhooks send messages as a card. So, the title and summary fields are mandatory. It is by design.
Solution 2:[2]
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
}),
)()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mamatha-MSFT |
Solution 2 | Moha Krs |