-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added flux teams package, resolves #1064
- Loading branch information
Showing
5 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
content/v2.0/reference/flux/stdlib/contrib/teams/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %}} |
78 changes: 78 additions & 0 deletions
78
content/v2.0/reference/flux/stdlib/contrib/teams/endpoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 %}} |
78 changes: 78 additions & 0 deletions
78
content/v2.0/reference/flux/stdlib/contrib/teams/message.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: teams.message() function | ||
description: > | ||
The `teams.message()` function sends a single message to a Microsoft Teams channel using | ||
a [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 %}} |