added flux pagerduty package

pull/438/head
Scott Anderson 2019-09-06 09:49:44 -06:00
parent 1c398b937c
commit 4784f6cc49
7 changed files with 306 additions and 0 deletions

View File

@ -7,6 +7,7 @@ menu:
name: http.endpoint
parent: HTTP
weight: 202
v2.0/tags: [endpoints]
---
The `http.endpoint()` function sends output data to an HTTP URL using the POST request method.

View File

@ -0,0 +1,22 @@
---
title: Flux PagerDuty package
list_title: PagerDuty package
description: >
The Flux PagerDuty package provides functions for sending data to PagerDuty.
Import the `pagerduty` package.
menu:
v2_0_ref:
name: PagerDuty
parent: Flux packages and functions
weight: 202
v2.0/tags: [functions, pagerduty, package]
---
The Flux PagerDuty package provides functions for sending data to PagerDuty.
Import the `pagerduty` package:
```js
import "pagerduty"
```
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,42 @@
---
title: pagerduty.actionFromSeverity() function
description: >
The `pagerduty.actionFromSeverity()` function converts a severity to a PagerDuty action.
menu:
v2_0_ref:
name: pagerduty.actionFromSeverity
parent: PagerDuty
weight: 202
---
The `pagerduty.actionFromSeverity()` function converts a severity to a PagerDuty action.
`ok` converts to `resolve`.
All other severities convert to `trigger`.
_**Function type:** Transformation_
```js
import "pagerduty"
pagerduty.actionFromSeverity(
severity: "ok"
)
// Returns "resolve"
```
## Parameters
### severity
The severity to convert to a PagerDuty action.
_**Data type:** String_
## Function definition
```js
import "strings"
actionFromSeverity = (severity) =>
if strings.toLower(v: severity) == "ok" then "resolve"
else "trigger"
```

View File

@ -0,0 +1,36 @@
---
title: pagerduty.dedupKey() function
description: >
The `pagerduty.dedupKey()` function uses the group key of an input table to
generate and store a deduplication key in the `_pagerdutyDedupKey` column.
menu:
v2_0_ref:
name: pagerduty.dedupKey
parent: PagerDuty
weight: 202
---
The `pagerduty.dedupKey()` function uses the group key of an input table to
generate and store a deduplication key in the `_pagerdutyDedupKey` column.
The function sorts, newline-concatenates, SHA256-hashes, and hex-encodes
the group key before storing it.
_**Function type:** Transformation_
```js
import "pagerduty"
pagerduty.dedupKey()
```
## Examples
##### Add a PagerDuty deduplication key to output data
```js
import "pagerduty"
from(bucket: "default")
|> range(start: -5m)
|> filter(fn: (r) => r._measurement == "mem")
|> pagerduty.dedupKey()
```

View File

@ -0,0 +1,81 @@
---
title: pagerduty.endpoint() function
description: >
The `pagerduty.endpoint()` function sends a message to PagerDuty that includes output data.
menu:
v2_0_ref:
name: pagerduty.endpoint
parent: PagerDuty
weight: 202
v2.0/tags: [endpoints]
---
The `pagerduty.endpoint()` function sends a message to PagerDuty that includes output data.
_**Function type:** Output_
```js
import "pagerduty"
pagerduty.endpoint(
url: "https://events.pagerduty.com/v2/enqueue",
token: "mySuPerSecRetTokEn"
)
```
## Parameters
### pagerdutyURL
The PagerDuty API URL.
Defaults to `https://events.pagerduty.com/v2/enqueue`.
_**Data type:** String_
### token
The [PagerDuty API token](https://support.pagerduty.com/docs/generating-api-keys#section-generating-a-general-access-rest-api-key)
used to interact with PagerDuty.
Defaults to `""`.
_**Data type:** String_
### mapFn
A function that builds the object used to generate the POST request.
{{% note %}}
_You should rarely need to override the default `mapFn` parameter.
To see the default `mapFn` value or for insight into possible overrides, view the
[`pagerduty.endpoint()` source code](https://github.com/influxdata/flux/blob/master/stdlib/pagerduty/pagerduty.flux)._
{{% /note %}}
_**Data type:** Function_
The returned object must include the following fields:
- `routingKey`
- `client`
- `client_url`
- `class`
- `group`
- `severity`
- `component`
- `source`
- `summary`
- `timestamp`
_For more information, see [`pagerduty.message()`](/v2.0/reference/flux/functions/pagerduty/message/)_
## Examples
##### Send critical statuses to a PagerDuty endpoint
```js
import "monitor"
import "pagerduty"
endpoint = pagerduty.endpoint(token: "mySuPerSecRetTokEn")
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
|> map(fn: (r) => { return {r with status: r._status} })
|> monitor.notify(endpoint: endpoint)
```

View File

@ -0,0 +1,123 @@
---
title: pagerduty.sendEvent() function
description: >
The `pagerduty.sendEvent()` function sends an event to PagerDuty.
menu:
v2_0_ref:
name: pagerduty.sendEvent
parent: PagerDuty
weight: 202
---
The `pagerduty.sendEvent()` function sends an event to PagerDuty.
_**Function type:** Output_
```js
import "pagerduty"
pagerduty.sendEvent(
pagerdutyURL: "https://events.pagerduty.com/v2/enqueue",
token: "mySuPerSecRetTokEn",
routingKey: "ExampleRoutingKey",
client: "ExampleClient",
clientURL: "http://examplepagerdutyclient.com",
dedupkey: "ExampleDedupKey",
class: "cpu usage",
group: "app-stack",
severity: "ok",
component: "postgres",
source: "monitoringtool:vendor:region",
summary: "This is an example summary.",
timestamp: "2016-07-17T08:42:58.315+0000"
)
```
## Parameters
### pagerdutyURL
The URL of the PagerDuty endpoint.
Defaults to `https://events.pagerduty.com/v2/enqueue`.
_**Data type:** String_
### token
The [PagerDuty API token](https://support.pagerduty.com/docs/generating-api-keys#section-generating-a-general-access-rest-api-key)
used to interact with PagerDuty.
Defaults to `""`.
_**Data type:** String_
### routingKey
The routing key generated from your PagerDuty integration.
_**Data type:** String_
### client
The name of the client sending the alert.
_**Data type:** String_
### clientURL
The URL of the client sending the alert.
_**Data type:** String_
### dedupkey
A per-alert ID that acts as deduplication key and allows you to acknowledge or
change the severity of previous messages.
Supports a maximum of 255 characters.
{{% note %}}
When using [`pagerduty.endpoint()`](/v2.0/reference/flux/functions/pagerduty/endpoint/)
to send data to PagerDuty, the function uses the [`pagerduty.dedupKey()` function](/v2.0/reference/flux/functions/pagerduty/dedupkey/) to populate the `dedupkey` parameter.
{{% /note %}}
_**Data type:** String_
### class
The class or type of the event.
For example, `ping failure` or `cpu load`.
_**Data type:** String_
### group
A logical grouping used by PagerDuty.
For example, `app-stack`.
_**Data type:** String_
### severity
The severity of the event.
**Valid values include:**
- `critical`
- `error`
- `warning`
- `info`
_**Data type:** String_
### component
The component of the source machine responsible for the event.
For example, `mysql` or `eth0`.
_**Data type:** String_
### source
The unique location of the affected system.
For example, the hostname or fully qualified domain name (FQDN).
_**Data type:** String_
### summary
A brief text summary of the event used as the summaries or titles of associated alerts.
The maximum permitted length is 1024 characters.
_**Data type:** String_
### timestamp
The time the detected event occurred in [RFC3339nano format](https://golang.org/pkg/time/#RFC3339Nano).
_**Data type:** String_

View File

@ -7,6 +7,7 @@ menu:
name: slack.endpoint
parent: Slack
weight: 202
v2.0/tags: [endpoints]
---
The `slack.endpoint()` function sends a message to Slack that includes output data.