Merge pull request #450 from influxdata/flux-0.45

Flux 0.45
pull/427/head
Scott Anderson 2019-09-09 19:53:56 -06:00 committed by GitHub
commit 259a5f3508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 380 additions and 1 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 to create a unique deduplication key for each input table.
_**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,73 @@
---
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"
)
```
## Parameters
### pagerdutyURL
The PagerDuty API URL.
Defaults to `https://events.pagerduty.com/v2/enqueue`.
_**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,129 @@
---
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",
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_
### 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.
Classes are user-defined.
For example, `ping failure` or `cpu load`.
_**Data type:** String_
### group
A logical grouping used by PagerDuty.
Groups are user-defined.
For example, `app-stack`.
_**Data type:** String_
### severity
The severity of the event.
**Valid values include:**
- `critical`
- `error`
- `warning`
- `info`
_**Data type:** String_
### eventAction
The type of event to send to PagerDuty.
**Valid values include:**
- `trigger`
- `resolve`
- `acknowledge`
_**Data type:** String_
### component
The component of the source machine responsible for the event.
Components are user-defined.
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

@ -0,0 +1,55 @@
---
title: pagerduty.severityFromLevel() function
description: >
The `pagerduty.severityFromLevel()` function converts an InfluxDB status level to
a PagerDuty severity.
menu:
v2_0_ref:
name: pagerduty.severityFromLevel
parent: PagerDuty
weight: 202
---
The `pagerduty.severityFromLevel()` function converts an InfluxDB status level to
a PagerDuty severity.
_**Function type:** Transformation_
```js
import "pagerduty"
pagerduty.severityFromLevel(
level: "crit"
)
// Returns "critical"
```
| Status level | PagerDuty severity |
|:------------:|:------------------:|
| `crit` | `critical` |
| `warn` | `warning` |
| `info` | `info` |
| `ok` | `info` |
## Parameters
### level
The InfluxDB status level to convert to a PagerDuty severity.
_**Data type:** String_
## Function definition
```js
import "strings"
severityFromLevel = (level) => {
lvl = strings.toLower(v:level)
sev = if lvl == "warn" then "warning"
else if lvl == "crit" then "critical"
else if lvl == "info" then "info"
else if lvl == "ok" then "info"
else "error"
return sev
}
```

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.

View File

@ -11,13 +11,33 @@ aliases:
---
{{% note %}}
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.43.0**.
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.45.1**.
Though newer versions of Flux may be available, they will not be included with
InfluxDB until the next InfluxDB v2.0 release._
{{% /note %}}
---
## v0.45.1 [2019-09-09]
### Bug fixes
- Ensure `http.post` respects the context.
---
## v0.45.0 [2019-09-06]
### Features
- Added Google Bigtable `from()`.
### Bug fixes
- Add `pagerduty.severityFromLevel()` helper function.
- Sleep function now gets canceled when the context is canceled.
- Categorize the undefined identifier as an invalid status code.
- Panic from `CheckKind` in `memberEvaluator`.
---
## v0.44.0 [2019-09-05]
### Features