commit
ae81534fc6
|
@ -5,7 +5,7 @@ description: >
|
|||
User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: User-contributed
|
||||
name: Contributed
|
||||
parent: Flux standard library
|
||||
weight: 202
|
||||
v2.0/tags: [contributed, functions, package]
|
||||
|
|
|
@ -7,7 +7,7 @@ description: >
|
|||
menu:
|
||||
v2_0_ref:
|
||||
name: Discord
|
||||
parent: User-contributed
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
v2.0/tags: [functions, discord, package]
|
||||
---
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title: Flux Microsoft Teams package
|
||||
list_title: Microsoft Teams package
|
||||
description: >
|
||||
The Flux Microsoft Teams package provides functions for sending messages to a
|
||||
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
|
||||
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
Import the `contrib/sranka/teams` package.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Teams
|
||||
parent: Contributed
|
||||
weight: 202
|
||||
v2.0/tags: [functions, teams, microsoft, package]
|
||||
---
|
||||
|
||||
The Flux Microsoft Teams package provides functions for sending messages to a
|
||||
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
|
||||
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
Import the `contrib/sranka/teams` package:
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
```
|
||||
|
||||
{{< children type="functions" show="pages" >}}
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: teams.endpoint() function
|
||||
description: >
|
||||
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
|
||||
using data from table rows.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: teams.endpoint
|
||||
parent: Teams
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
|
||||
using data from table rows.
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
teams.endpoint(
|
||||
url: "https://outlook.office.com/webhook/example-webhook"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
Incoming webhook URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Usage
|
||||
`teams.endpoint` is a factory function that outputs another function.
|
||||
The output function requires a `mapFn` parameter.
|
||||
|
||||
### mapFn
|
||||
A function that builds the object used to generate the POST request.
|
||||
Requires an `r` parameter.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
`mapFn` accepts a table row (`r`) and returns an object that must include the
|
||||
following fields:
|
||||
|
||||
- `title`
|
||||
- `text`
|
||||
- `summary`
|
||||
|
||||
_For more information, see [`teams.message()`](/v2.0/reference/flux/stdlib/contrib/teams/message/)._
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send critical statuses to a Microsoft Teams channel
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
url = "https://outlook.office.com/webhook/example-webhook"
|
||||
endpoint = teams.endpoint(url: url)
|
||||
|
||||
crit_statuses = from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
|
||||
|
||||
crit_statuses
|
||||
|> endpoint(mapFn: (r) => ({
|
||||
title: "Disk Usage"
|
||||
text: "Disk usage is: **${r.status}**.",
|
||||
summary: "Disk usage is ${r.status}"
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
title: teams.message() function
|
||||
description: >
|
||||
The `teams.message()` function sends a single message to a Microsoft Teams channel using
|
||||
an [incoming webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3).
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: teams.message
|
||||
parent: Teams
|
||||
weight: 202
|
||||
---
|
||||
|
||||
The `teams.message()` function sends a single message to a Microsoft Teams channel using
|
||||
an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
|
||||
|
||||
_**Function type:** Output_
|
||||
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
teams.message(
|
||||
url: "https://outlook.office.com/webhook/example-webhook",
|
||||
title: "Example message title",
|
||||
text: "Example message text",
|
||||
summary: "",
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### url
|
||||
Incoming webhook URL.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### title
|
||||
Message card title.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### text
|
||||
Message card text.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### summary
|
||||
Message card summary.
|
||||
Default is `""`.
|
||||
If no summary is provided, Flux generates the summary from the message text.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Send the last reported status to a Microsoft Teams channel
|
||||
```js
|
||||
import "contrib/sranka/teams"
|
||||
|
||||
lastReported =
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -1m)
|
||||
|> filter(fn: (r) => r._measurement == "statuses")
|
||||
|> last()
|
||||
|> findRecord(fn: (key) => true, idx: 0)
|
||||
|
||||
teams.message(
|
||||
url: "https://outlook.office.com/webhook/example-webhook",
|
||||
title: "Disk Usage"
|
||||
text: "Disk usage is: *${lastReported.status}*.",
|
||||
summary: "Disk usage is ${lastReported.status}"
|
||||
)
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
Loading…
Reference in New Issue