From 4784f6cc499db7ea7aea4e2fc49822504abb2b72 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 6 Sep 2019 09:49:44 -0600 Subject: [PATCH] added flux pagerduty package --- .../reference/flux/functions/http/endpoint.md | 1 + .../flux/functions/pagerduty/_index.md | 22 ++++ .../functions/pagerduty/actionfromseverity.md | 42 ++++++ .../flux/functions/pagerduty/dedupkey.md | 36 +++++ .../flux/functions/pagerduty/endpoint.md | 81 ++++++++++++ .../flux/functions/pagerduty/sendevent.md | 123 ++++++++++++++++++ .../flux/functions/slack/endpoint.md | 1 + 7 files changed, 306 insertions(+) create mode 100644 content/v2.0/reference/flux/functions/pagerduty/_index.md create mode 100644 content/v2.0/reference/flux/functions/pagerduty/actionfromseverity.md create mode 100644 content/v2.0/reference/flux/functions/pagerduty/dedupkey.md create mode 100644 content/v2.0/reference/flux/functions/pagerduty/endpoint.md create mode 100644 content/v2.0/reference/flux/functions/pagerduty/sendevent.md diff --git a/content/v2.0/reference/flux/functions/http/endpoint.md b/content/v2.0/reference/flux/functions/http/endpoint.md index 6b316bf27..df67ea6af 100644 --- a/content/v2.0/reference/flux/functions/http/endpoint.md +++ b/content/v2.0/reference/flux/functions/http/endpoint.md @@ -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. diff --git a/content/v2.0/reference/flux/functions/pagerduty/_index.md b/content/v2.0/reference/flux/functions/pagerduty/_index.md new file mode 100644 index 000000000..8a8a1fd13 --- /dev/null +++ b/content/v2.0/reference/flux/functions/pagerduty/_index.md @@ -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" >}} diff --git a/content/v2.0/reference/flux/functions/pagerduty/actionfromseverity.md b/content/v2.0/reference/flux/functions/pagerduty/actionfromseverity.md new file mode 100644 index 000000000..6ac966f05 --- /dev/null +++ b/content/v2.0/reference/flux/functions/pagerduty/actionfromseverity.md @@ -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" +``` diff --git a/content/v2.0/reference/flux/functions/pagerduty/dedupkey.md b/content/v2.0/reference/flux/functions/pagerduty/dedupkey.md new file mode 100644 index 000000000..a932cd754 --- /dev/null +++ b/content/v2.0/reference/flux/functions/pagerduty/dedupkey.md @@ -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() +``` diff --git a/content/v2.0/reference/flux/functions/pagerduty/endpoint.md b/content/v2.0/reference/flux/functions/pagerduty/endpoint.md new file mode 100644 index 000000000..cd3a63ffc --- /dev/null +++ b/content/v2.0/reference/flux/functions/pagerduty/endpoint.md @@ -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) +``` diff --git a/content/v2.0/reference/flux/functions/pagerduty/sendevent.md b/content/v2.0/reference/flux/functions/pagerduty/sendevent.md new file mode 100644 index 000000000..2dfdd436b --- /dev/null +++ b/content/v2.0/reference/flux/functions/pagerduty/sendevent.md @@ -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_ diff --git a/content/v2.0/reference/flux/functions/slack/endpoint.md b/content/v2.0/reference/flux/functions/slack/endpoint.md index ea3ecbb7a..a4940de1a 100644 --- a/content/v2.0/reference/flux/functions/slack/endpoint.md +++ b/content/v2.0/reference/flux/functions/slack/endpoint.md @@ -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.