0

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 ?

Christos Michael
  • 1,003
  • 2
  • 10
  • 16
  • Hi @ChristosMichael - Please go through this [doc](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/contrib/teams/message/) to single message to a Microsoft Teams channel using an incoming webhook. – Mamatha-MSFT Jun 03 '21 at 09:00
  • Hello, @Mamatha-MSFT, thanks. I have noticed that, however this is not the way I want it to be used. – Christos Michael Jun 03 '21 at 10:43
  • @Mamatha-MSFT I wanted to be sent directly from alerts area. I can't understand why teams need to have summary or title as keys in order to work – Christos Michael Jun 03 '21 at 10:44

2 Answers2

2

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

Mamatha-MSFT
  • 577
  • 3
  • 4
  • I knnow, That's why am asking how to change influxDB request POST body – Christos Michael Jun 03 '21 at 13:18
  • @ChristosMichael - The incoming webhook has a specific format which is mentioned in the documentation, if your service do not send request in that format you could actually build intermediate service which can actually convert your payload to the one which matches the message format of the teams and send it across. – Mamatha-MSFT Jun 05 '21 at 10:31
1

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
    }),
  )()
Moha Krs
  • 11
  • 3