From 621f137f6376b7954097454a8a952c279ca1c38c Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 27 Aug 2019 08:33:33 -0600 Subject: [PATCH 01/13] WIP monitor package --- .../flux/functions/monitor/_index.md | 22 +++++++++++ .../reference/flux/functions/monitor/check.md | 38 +++++++++++++++++++ .../flux/functions/monitor/deadman.md | 38 +++++++++++++++++++ .../reference/flux/functions/monitor/from.md | 36 ++++++++++++++++++ .../reference/flux/functions/monitor/logs.md | 36 ++++++++++++++++++ .../flux/functions/monitor/notify.md | 36 ++++++++++++++++++ 6 files changed, 206 insertions(+) create mode 100644 content/v2.0/reference/flux/functions/monitor/_index.md create mode 100644 content/v2.0/reference/flux/functions/monitor/check.md create mode 100644 content/v2.0/reference/flux/functions/monitor/deadman.md create mode 100644 content/v2.0/reference/flux/functions/monitor/from.md create mode 100644 content/v2.0/reference/flux/functions/monitor/logs.md create mode 100644 content/v2.0/reference/flux/functions/monitor/notify.md diff --git a/content/v2.0/reference/flux/functions/monitor/_index.md b/content/v2.0/reference/flux/functions/monitor/_index.md new file mode 100644 index 000000000..abb196eed --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux Monitor package +list_title: Monitor package +description: > + The Flux Monitor package provides tools for monitoring and alerting. + Import the `influxdata/influxdb/monitor` package. +menu: + v2_0_ref: + name: Monitor + parent: Flux packages and functions +weight: 202 +v2.0/tags: [functions, monitor, alerts, package] +--- + +Monitor Flux functions provide tools for monitoring and alerting. +Import the `influxdata/influxdb/monitor` package: + +```js +import "influxdata/influxdb/monitor" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/monitor/check.md b/content/v2.0/reference/flux/functions/monitor/check.md new file mode 100644 index 000000000..b44af1657 --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/check.md @@ -0,0 +1,38 @@ +--- +title: monitor.check() function +description: The `monitor.check()` function ... +menu: + v2_0_ref: + name: monitor.check + parent: Monitor +weight: 202 +--- + +The `monitor.check()` function ... + +_**Function type:** Type conversion_ + +```js +import "influxdata/influxdb/monitor" + +monitor.check(...) +``` + + +## Parameters + +### v +The value to convert. + +_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ + +## Examples + +### ... +```js +import "influxdata/influxdb/monitor" + +from(bucket: "example-bucket") + |> range(start: -1h) + |> monitor.check(...) +``` diff --git a/content/v2.0/reference/flux/functions/monitor/deadman.md b/content/v2.0/reference/flux/functions/monitor/deadman.md new file mode 100644 index 000000000..7f7d29e10 --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/deadman.md @@ -0,0 +1,38 @@ +--- +title: monitor.deadman() function +description: The `monitor.deadman()` function ... +menu: + v2_0_ref: + name: monitor.deadman + parent: Monitor +weight: 202 +--- + +The `monitor.deadman()` function ... + +_**Function type:** Type conversion_ + +```js +import "influxdata/influxdb/monitor" + +monitor.deadman(...) +``` + + +## Parameters + +### v +The value to convert. + +_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ + +## Examples + +### ... +```js +import "influxdata/influxdb/monitor" + +from(bucket: "example-bucket") + |> range(start: -1h) + |> monitor.deadman(...) +``` diff --git a/content/v2.0/reference/flux/functions/monitor/from.md b/content/v2.0/reference/flux/functions/monitor/from.md new file mode 100644 index 000000000..ae77376d8 --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/from.md @@ -0,0 +1,36 @@ +--- +title: monitor.from() function +description: The `monitor.from()` function ... +menu: + v2_0_ref: + name: monitor.from + parent: Monitor +weight: 202 +--- + +The `monitor.from()` function ... + +_**Function type:** Type conversion_ + +```js +import "influxdata/influxdb/monitor" + +monitor.from(...) +``` + + +## Parameters + +### v +The value to convert. + +_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ + +## Examples + +### ... +```js +import "influxdata/influxdb/monitor" + +monitor.from(...) +``` diff --git a/content/v2.0/reference/flux/functions/monitor/logs.md b/content/v2.0/reference/flux/functions/monitor/logs.md new file mode 100644 index 000000000..aa45f7e04 --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/logs.md @@ -0,0 +1,36 @@ +--- +title: monitor.logs() function +description: The `monitor.logs()` function ... +menu: + v2_0_ref: + name: monitor.logs + parent: Monitor +weight: 202 +--- + +The `monitor.logs()` function ... + +_**Function type:** Type conversion_ + +```js +import "influxdata/influxdb/monitor" + +monitor.logs(...) +``` + + +## Parameters + +### v +The value to convert. + +_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ + +## Examples + +### ... +```js +import "influxdata/influxdb/monitor" + +monitor.logs(...) +``` diff --git a/content/v2.0/reference/flux/functions/monitor/notify.md b/content/v2.0/reference/flux/functions/monitor/notify.md new file mode 100644 index 000000000..3f777c78e --- /dev/null +++ b/content/v2.0/reference/flux/functions/monitor/notify.md @@ -0,0 +1,36 @@ +--- +title: monitor.notify() function +description: The `monitor.notify()` function ... +menu: + v2_0_ref: + name: monitor.notify + parent: Monitor +weight: 202 +--- + +The `monitor.notify()` function ... + +_**Function type:** Type conversion_ + +```js +import "influxdata/influxdb/monitor" + +monitor.notify(...) +``` + + +## Parameters + +### v +The value to convert. + +_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ + +## Examples + +### ... +```js +import "influxdata/influxdb/monitor" + +monitor.notify(...) +``` From 31e669f5903dd232d0632de0e83754b25f89279b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 27 Aug 2019 14:27:51 -0600 Subject: [PATCH 02/13] WIP updated monitor.from and monitor.notify functions --- .../reference/flux/functions/monitor/from.md | 52 +++++++++++++++---- .../flux/functions/monitor/notify.md | 34 ++++++++---- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/content/v2.0/reference/flux/functions/monitor/from.md b/content/v2.0/reference/flux/functions/monitor/from.md index ae77376d8..110d9a123 100644 --- a/content/v2.0/reference/flux/functions/monitor/from.md +++ b/content/v2.0/reference/flux/functions/monitor/from.md @@ -1,6 +1,7 @@ --- title: monitor.from() function -description: The `monitor.from()` function ... +description: > + The `monitor.from()` function retrieves check statuses stored in the `_monitoring` bucket. menu: v2_0_ref: name: monitor.from @@ -8,29 +9,62 @@ menu: weight: 202 --- -The `monitor.from()` function ... +The `monitor.from()` function retrieves check statuses stored in the `_monitoring` bucket. -_**Function type:** Type conversion_ +_**Function type:** Input_ ```js import "influxdata/influxdb/monitor" -monitor.from(...) +monitor.from( + start: -1h, + stop: now(), + fn: (r) => true +) ``` ## Parameters -### v -The value to convert. +### start +The oldest time to include in results. -_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ +Relative start times are defined using negative durations. +Negative durations are relative to now. +Absolute start times are defined using timestamps. + +_**Data type:** Duration | Time_ + +### stop +The newest time to include in the results. +Defaults to `now()`. + +Relative stop times are defined using negative durations. +Negative durations are relative to now. +Absolute stop times are defined using timestamps. + +_**Data type:** Duration | Time_ + +{{% note %}} +Flux only honors [RFC3339 timestamps](/v2.0/reference/flux/language/types#timestamp-format) +and ignores dates and times provided in other formats. +{{% /note %}} + +### fn +A single argument predicate function that evaluates `true` or `false`. +Records or rows (`r`) that evaluate to `true` are included in output tables. +Records that evaluate to _null_ or `false` are not included in output tables. + +_**Data type:** Function_ ## Examples -### ... +### View critical check statuses from the last hour ```js import "influxdata/influxdb/monitor" -monitor.from(...) +monitor.from( + start: -1h, + fn: (r) => r._level == "crit" +) ``` diff --git a/content/v2.0/reference/flux/functions/monitor/notify.md b/content/v2.0/reference/flux/functions/monitor/notify.md index 3f777c78e..c1dc0fd0a 100644 --- a/content/v2.0/reference/flux/functions/monitor/notify.md +++ b/content/v2.0/reference/flux/functions/monitor/notify.md @@ -1,6 +1,8 @@ --- title: monitor.notify() function -description: The `monitor.notify()` function ... +description: > + The `monitor.notify()` function sends a notification to an endpoint and logs it + in the `notifications` measurement in the `_monitoring` bucket. menu: v2_0_ref: name: monitor.notify @@ -8,29 +10,43 @@ menu: weight: 202 --- -The `monitor.notify()` function ... +The `monitor.notify()` function sends a notification to an endpoint and logs it +in the `notifications` measurement in the `_monitoring` bucket. _**Function type:** Type conversion_ ```js import "influxdata/influxdb/monitor" -monitor.notify(...) +monitor.notify( + endpoint: , + data: {} +) ``` - ## Parameters -### v -The value to convert. +### endpoint +A function that constructs and sends the notification to an endpoint. -_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ +_**Data type:** Function_ + +### data +The data object to send to the endpoint. +Defaults to `{}`. + +_**Data type:** Object_ ## Examples -### ... +### Send a notification to Slack ```js import "influxdata/influxdb/monitor" +import "slack" -monitor.notify(...) +endpoint = slack.endpoint(name: "slack", channel: "#flux") + +from(bucket: "system") + |> range(start: -5m) + |> monitor.notify(endpoint: endpoint) ``` From 428faa0ee89e5085441499cf21727f26a3704391 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 29 Aug 2019 08:59:38 -0600 Subject: [PATCH 03/13] WIP added monitor.logs, working on monitor.deadman --- .../flux/functions/monitor/_index.md | 2 +- .../flux/functions/monitor/deadman.md | 15 ++++-- .../reference/flux/functions/monitor/logs.md | 50 +++++++++++++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/content/v2.0/reference/flux/functions/monitor/_index.md b/content/v2.0/reference/flux/functions/monitor/_index.md index abb196eed..3e0af6b67 100644 --- a/content/v2.0/reference/flux/functions/monitor/_index.md +++ b/content/v2.0/reference/flux/functions/monitor/_index.md @@ -12,7 +12,7 @@ weight: 202 v2.0/tags: [functions, monitor, alerts, package] --- -Monitor Flux functions provide tools for monitoring and alerting. +Monitor Flux functions provide tools for monitoring and alerting with InfluxDB. Import the `influxdata/influxdb/monitor` package: ```js diff --git a/content/v2.0/reference/flux/functions/monitor/deadman.md b/content/v2.0/reference/flux/functions/monitor/deadman.md index 7f7d29e10..ead39c1f2 100644 --- a/content/v2.0/reference/flux/functions/monitor/deadman.md +++ b/content/v2.0/reference/flux/functions/monitor/deadman.md @@ -1,23 +1,30 @@ --- title: monitor.deadman() function -description: The `monitor.deadman()` function ... +description: > + The `monitor.deadman()` function detects when a group stops reporting data. menu: v2_0_ref: name: monitor.deadman parent: Monitor weight: 202 +cloud_all: true --- -The `monitor.deadman()` function ... +The `monitor.deadman()` function detects when a group stops reporting data. +It takes a stream of tables and reports which groups or series are +observed before time `t`, but not after. -_**Function type:** Type conversion_ +_**Function type:** Transformation_ ```js import "influxdata/influxdb/monitor" -monitor.deadman(...) +monitor.deadman(t: -3m) ``` +`monitor.deadman()` retains the most recent row from each input table. +It adds a `dead` column to output tables. +If a group or series and sets it to `true` if the row's gro ## Parameters diff --git a/content/v2.0/reference/flux/functions/monitor/logs.md b/content/v2.0/reference/flux/functions/monitor/logs.md index aa45f7e04..018cf0c47 100644 --- a/content/v2.0/reference/flux/functions/monitor/logs.md +++ b/content/v2.0/reference/flux/functions/monitor/logs.md @@ -1,6 +1,7 @@ --- title: monitor.logs() function -description: The `monitor.logs()` function ... +description: > + The `monitor.logs()` function retrieves notification events stored in the `_monitoring` bucket. menu: v2_0_ref: name: monitor.logs @@ -8,29 +9,58 @@ menu: weight: 202 --- -The `monitor.logs()` function ... +The `monitor.logs()` function retrieves notification events stored in the `_monitoring` bucket. -_**Function type:** Type conversion_ +_**Function type:** Input_ ```js import "influxdata/influxdb/monitor" -monitor.logs(...) +monitor.logs( + start: -1h, + stop: now(), + fn: (r) => true +) ``` - ## Parameters -### v -The value to convert. +### start +The oldest time to include in results. -_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ +Relative start times are defined using negative durations. +Negative durations are relative to now. +Absolute start times are defined using timestamps. + +_**Data type:** Duration | Time_ + +### stop +The newest time to include in the results. +Defaults to `now()`. + +Relative stop times are defined using negative durations. +Negative durations are relative to now. +Absolute stop times are defined using timestamps. + +_**Data type:** Duration | Time_ + +{{% note %}} +Flux only honors [RFC3339 timestamps](/v2.0/reference/flux/language/types#timestamp-format) +and ignores dates and times provided in other formats. +{{% /note %}} + +### fn +A single argument predicate function that evaluates `true` or `false`. +Records or rows (`r`) that evaluate to `true` are included in output tables. +Records that evaluate to _null_ or `false` are not included in output tables. + +_**Data type:** Function_ ## Examples -### ... +### Query notification events from the last hour ```js import "influxdata/influxdb/monitor" -monitor.logs(...) +monitor.logs(start: -1h) ``` From 302b9b0171decb77f09b0faf0ca5e509b06a4699 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 29 Aug 2019 16:55:19 -0600 Subject: [PATCH 04/13] finshed deadman and check functions, resolves #377 --- .../flux/functions/monitor/_index.md | 8 +- .../reference/flux/functions/monitor/check.md | 80 ++++++++++++++++--- .../flux/functions/monitor/deadman.md | 22 ++--- .../reference/flux/functions/monitor/from.md | 2 +- .../reference/flux/functions/monitor/logs.md | 2 +- .../flux/functions/monitor/notify.md | 8 +- 6 files changed, 90 insertions(+), 32 deletions(-) diff --git a/content/v2.0/reference/flux/functions/monitor/_index.md b/content/v2.0/reference/flux/functions/monitor/_index.md index 3e0af6b67..bc57feadb 100644 --- a/content/v2.0/reference/flux/functions/monitor/_index.md +++ b/content/v2.0/reference/flux/functions/monitor/_index.md @@ -1,12 +1,12 @@ --- -title: Flux Monitor package -list_title: Monitor package +title: Flux InfluxDB Monitor package +list_title: InfluxDB Monitor package description: > - The Flux Monitor package provides tools for monitoring and alerting. + The Flux Monitor package provides tools for monitoring and alerting with InfluxDB. Import the `influxdata/influxdb/monitor` package. menu: v2_0_ref: - name: Monitor + name: InfluxDB Monitor parent: Flux packages and functions weight: 202 v2.0/tags: [functions, monitor, alerts, package] diff --git a/content/v2.0/reference/flux/functions/monitor/check.md b/content/v2.0/reference/flux/functions/monitor/check.md index b44af1657..67f6198ba 100644 --- a/content/v2.0/reference/flux/functions/monitor/check.md +++ b/content/v2.0/reference/flux/functions/monitor/check.md @@ -1,38 +1,94 @@ --- title: monitor.check() function -description: The `monitor.check()` function ... +description: > + The `monitor.check()` function performs a check against input data and assigns an `ok`, + `info`, `warn` or `crit`level to each row based on user-specified predicate functions. menu: v2_0_ref: name: monitor.check - parent: Monitor + parent: InfluxDB Monitor weight: 202 --- -The `monitor.check()` function ... +The `monitor.check()` function performs a check against input data and assigns an `ok`, +`info`, `warn` or `crit` level to each row based on user-specified predicate functions. +The function stores statuses in the `_level` column and writes all check results to the +`statuses` measurement in the `_monitoring` bucket. -_**Function type:** Type conversion_ +_**Function type:** Transformation_ ```js import "influxdata/influxdb/monitor" -monitor.check(...) +monitor.check( + crit: (r) => r._value > 90.0, + warn: (r) => r._value > 80.0, + info: (r) => r._value > 60.0, + ok: (r) => r._value <= 20.0, + messageFn: (r) => "The current level is ${r._level}", + data: {} +) ``` - ## Parameters -### v -The value to convert. +### crit +Predicate function that determines `crit` status. +Default is `(r) => false`. -_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ +_**Data type:** Function_ + +### warn +Predicate function that determines `warn` status. +Default is `(r) => false`. + +_**Data type:** Function_ + +### info +Predicate function that determines `info` status. +Default is `(r) => false`. + +_**Data type:** Function_ + +### ok +Predicate function that determines `ok` status. +Default is `(r) => true`. + +_**Data type:** Function_ + +### messageFn +A function that constructs a message to append to each row. +The message is stored in the `_message` column. + +_**Data type:** Function_ + +### data +Data to append to the to output data. +**InfluxDB populates check data.** + +_**Data type:** Object_ ## Examples -### ... +### Monitor disk usage ```js import "influxdata/influxdb/monitor" -from(bucket: "example-bucket") +from(bucket: "telegraf") |> range(start: -1h) - |> monitor.check(...) + |> filter(fn: (r) => + r._measurement == "disk" and + r._field = "used_percent" + ) + |> monitor.check( + crit: (r) => r._value > 90.0, + warn: (r) => r._value > 80.0, + info: (r) => r._value > 70.0, + ok: (r) => r._value <= 60.0, + messageFn: (r) => + if r._level == "crit" then "Critical alert!! Disk usage is at ${r._value}%!" + else if r._level == "warn" then "Warning! Disk usage is at ${r._value}%." + else if r._level == "info" then "Disk usage is at ${r._value}%." + else "Things are looking good." + ) ``` diff --git a/content/v2.0/reference/flux/functions/monitor/deadman.md b/content/v2.0/reference/flux/functions/monitor/deadman.md index ead39c1f2..1ae8286ff 100644 --- a/content/v2.0/reference/flux/functions/monitor/deadman.md +++ b/content/v2.0/reference/flux/functions/monitor/deadman.md @@ -5,7 +5,7 @@ description: > menu: v2_0_ref: name: monitor.deadman - parent: Monitor + parent: InfluxDB Monitor weight: 202 cloud_all: true --- @@ -22,24 +22,26 @@ import "influxdata/influxdb/monitor" monitor.deadman(t: -3m) ``` -`monitor.deadman()` retains the most recent row from each input table. -It adds a `dead` column to output tables. -If a group or series and sets it to `true` if the row's gro +`monitor.deadman()` retains the most recent row from each input table and adds a `dead` column. +It sets `dead` to `true` if the record appears before time `t`. +It sets `dead` to `false` if the group appears after time `t`. ## Parameters -### v -The value to convert. +### t +The time threshold for the deadman check. -_**Data type:** Boolean | Duration | Float | Integer | String | Time | UInteger_ +_**Data type:** Time_ ## Examples -### ... +### Detect if a host hasn't reported in the last five minutes ```js import "influxdata/influxdb/monitor" +import "experimental" from(bucket: "example-bucket") - |> range(start: -1h) - |> monitor.deadman(...) + |> range(start: -10m) + |> group(columns: ["host"]) + |> monitor.deadman(t: experimental.subDuration(d: 5m, from: now() )) ``` diff --git a/content/v2.0/reference/flux/functions/monitor/from.md b/content/v2.0/reference/flux/functions/monitor/from.md index 110d9a123..540006923 100644 --- a/content/v2.0/reference/flux/functions/monitor/from.md +++ b/content/v2.0/reference/flux/functions/monitor/from.md @@ -5,7 +5,7 @@ description: > menu: v2_0_ref: name: monitor.from - parent: Monitor + parent: InfluxDB Monitor weight: 202 --- diff --git a/content/v2.0/reference/flux/functions/monitor/logs.md b/content/v2.0/reference/flux/functions/monitor/logs.md index 018cf0c47..1ed8ad486 100644 --- a/content/v2.0/reference/flux/functions/monitor/logs.md +++ b/content/v2.0/reference/flux/functions/monitor/logs.md @@ -5,7 +5,7 @@ description: > menu: v2_0_ref: name: monitor.logs - parent: Monitor + parent: InfluxDB Monitor weight: 202 --- diff --git a/content/v2.0/reference/flux/functions/monitor/notify.md b/content/v2.0/reference/flux/functions/monitor/notify.md index c1dc0fd0a..ac671fcf6 100644 --- a/content/v2.0/reference/flux/functions/monitor/notify.md +++ b/content/v2.0/reference/flux/functions/monitor/notify.md @@ -6,14 +6,14 @@ description: > menu: v2_0_ref: name: monitor.notify - parent: Monitor + parent: InfluxDB Monitor weight: 202 --- The `monitor.notify()` function sends a notification to an endpoint and logs it in the `notifications` measurement in the `_monitoring` bucket. -_**Function type:** Type conversion_ +_**Function type:** Output_ ```js import "influxdata/influxdb/monitor" @@ -32,8 +32,8 @@ A function that constructs and sends the notification to an endpoint. _**Data type:** Function_ ### data -The data object to send to the endpoint. -Defaults to `{}`. +Data to append to output data. +**InfluxDB populates notification data.** _**Data type:** Object_ From cb74dbffe37b091ab8dd95fd8ccc7b30e2bc23d1 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 30 Aug 2019 09:09:33 -0600 Subject: [PATCH 05/13] updated monitor package docs to address PR feedback --- .../built-in/transformations/range.md | 26 +++++++++---------- .../flux/functions/monitor/_index.md | 2 +- .../reference/flux/functions/monitor/check.md | 15 ++++++----- .../flux/functions/monitor/deadman.md | 7 +++-- .../reference/flux/functions/monitor/from.md | 21 +++++++-------- .../reference/flux/functions/monitor/logs.md | 21 +++++++-------- .../flux/functions/monitor/notify.md | 2 +- 7 files changed, 43 insertions(+), 51 deletions(-) diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/range.md b/content/v2.0/reference/flux/functions/built-in/transformations/range.md index bb7a142b4..371cce541 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/range.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/range.md @@ -26,26 +26,24 @@ range(start: -15m, stop: now()) ## Parameters ### start -Specifies the oldest time to be included in the results. +The earliest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using timestamps. - -_**Data type:** Duration or Timestamp_ +_**Data type:** Duration | Time_ ### stop -Specifies the newest time to be included in the results. Defaults to `now`. +The latest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. +Defaults to `now()`. -Relative stop times are defined using negative durations. -Negative durations are relative to now. -Absolute stop times are defined using timestamps. - -_**Data type:** Duration or Timestamp_ +_**Data type:** Duration | Time_ {{% note %}} -Flux only honors [RFC3339 timestamps](/v2.0/reference/flux/language/types#timestamp-format) -and ignores dates and times provided in other formats. +Time values in Flux must be in [RFC3339 format](/v2.0/reference/flux/language/types#timestamp-format). {{% /note %}} ## Examples diff --git a/content/v2.0/reference/flux/functions/monitor/_index.md b/content/v2.0/reference/flux/functions/monitor/_index.md index bc57feadb..12271be11 100644 --- a/content/v2.0/reference/flux/functions/monitor/_index.md +++ b/content/v2.0/reference/flux/functions/monitor/_index.md @@ -12,7 +12,7 @@ weight: 202 v2.0/tags: [functions, monitor, alerts, package] --- -Monitor Flux functions provide tools for monitoring and alerting with InfluxDB. +The Flux monitor package provides tools for monitoring and alerting with InfluxDB. Import the `influxdata/influxdb/monitor` package: ```js diff --git a/content/v2.0/reference/flux/functions/monitor/check.md b/content/v2.0/reference/flux/functions/monitor/check.md index 67f6198ba..ce8de7b7f 100644 --- a/content/v2.0/reference/flux/functions/monitor/check.md +++ b/content/v2.0/reference/flux/functions/monitor/check.md @@ -1,8 +1,8 @@ --- title: monitor.check() function description: > - The `monitor.check()` function performs a check against input data and assigns an `ok`, - `info`, `warn` or `crit`level to each row based on user-specified predicate functions. + The `monitor.check()` function function checks input data and assigns a level + (`ok`, `info`, `warn`, or `crit`) to each row based on predicate functions. menu: v2_0_ref: name: monitor.check @@ -10,10 +10,8 @@ menu: weight: 202 --- -The `monitor.check()` function performs a check against input data and assigns an `ok`, -`info`, `warn` or `crit` level to each row based on user-specified predicate functions. -The function stores statuses in the `_level` column and writes all check results to the -`statuses` measurement in the `_monitoring` bucket. +The `monitor.check()` function function checks input data and assigns a level +(`ok`, `info`, `warn`, or `crit`) to each row based on predicate functions. _**Function type:** Transformation_ @@ -30,6 +28,9 @@ monitor.check( ) ``` +`monitor.check()` stores statuses in the `_level` column and writes results +to the `statuses` measurement in the `_monitoring` bucket. + ## Parameters ### crit @@ -63,7 +64,7 @@ The message is stored in the `_message` column. _**Data type:** Function_ ### data -Data to append to the to output data. +Data to append to the output. **InfluxDB populates check data.** _**Data type:** Object_ diff --git a/content/v2.0/reference/flux/functions/monitor/deadman.md b/content/v2.0/reference/flux/functions/monitor/deadman.md index 1ae8286ff..08a030398 100644 --- a/content/v2.0/reference/flux/functions/monitor/deadman.md +++ b/content/v2.0/reference/flux/functions/monitor/deadman.md @@ -11,8 +11,7 @@ cloud_all: true --- The `monitor.deadman()` function detects when a group stops reporting data. -It takes a stream of tables and reports which groups or series are -observed before time `t`, but not after. +It takes a stream of tables and reports if groups have been observed since time `t`. _**Function type:** Transformation_ @@ -23,8 +22,8 @@ monitor.deadman(t: -3m) ``` `monitor.deadman()` retains the most recent row from each input table and adds a `dead` column. -It sets `dead` to `true` if the record appears before time `t`. -It sets `dead` to `false` if the group appears after time `t`. +If a record appears **after** time `t`, `monitor.deadman()` sets `dead` to `false`. +Otherwise, `dead` is set to `true`. ## Parameters diff --git a/content/v2.0/reference/flux/functions/monitor/from.md b/content/v2.0/reference/flux/functions/monitor/from.md index 540006923..2c97ed710 100644 --- a/content/v2.0/reference/flux/functions/monitor/from.md +++ b/content/v2.0/reference/flux/functions/monitor/from.md @@ -27,27 +27,24 @@ monitor.from( ## Parameters ### start -The oldest time to include in results. - -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using timestamps. +The earliest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. _**Data type:** Duration | Time_ ### stop -The newest time to include in the results. +The latest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. Defaults to `now()`. -Relative stop times are defined using negative durations. -Negative durations are relative to now. -Absolute stop times are defined using timestamps. - _**Data type:** Duration | Time_ {{% note %}} -Flux only honors [RFC3339 timestamps](/v2.0/reference/flux/language/types#timestamp-format) -and ignores dates and times provided in other formats. +Time values in Flux must be in [RFC3339 format](/v2.0/reference/flux/language/types#timestamp-format). {{% /note %}} ### fn diff --git a/content/v2.0/reference/flux/functions/monitor/logs.md b/content/v2.0/reference/flux/functions/monitor/logs.md index 1ed8ad486..5b13f9c14 100644 --- a/content/v2.0/reference/flux/functions/monitor/logs.md +++ b/content/v2.0/reference/flux/functions/monitor/logs.md @@ -26,27 +26,24 @@ monitor.logs( ## Parameters ### start -The oldest time to include in results. - -Relative start times are defined using negative durations. -Negative durations are relative to now. -Absolute start times are defined using timestamps. +The earliest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. _**Data type:** Duration | Time_ ### stop -The newest time to include in the results. +The latest time to include in results. +Use a relative duration or absolute time. +For example, `-1h` or `2019-08-28T22:00:00Z`. +Durations are relative to `now()`. Defaults to `now()`. -Relative stop times are defined using negative durations. -Negative durations are relative to now. -Absolute stop times are defined using timestamps. - _**Data type:** Duration | Time_ {{% note %}} -Flux only honors [RFC3339 timestamps](/v2.0/reference/flux/language/types#timestamp-format) -and ignores dates and times provided in other formats. +Time values in Flux must be in [RFC3339 format](/v2.0/reference/flux/language/types#timestamp-format). {{% /note %}} ### fn diff --git a/content/v2.0/reference/flux/functions/monitor/notify.md b/content/v2.0/reference/flux/functions/monitor/notify.md index ac671fcf6..e596600fd 100644 --- a/content/v2.0/reference/flux/functions/monitor/notify.md +++ b/content/v2.0/reference/flux/functions/monitor/notify.md @@ -32,7 +32,7 @@ A function that constructs and sends the notification to an endpoint. _**Data type:** Function_ ### data -Data to append to output data. +Data to append to the output. **InfluxDB populates notification data.** _**Data type:** Object_ From 6ea36fe096dc4eeb82d6c953eec02aa1114a1043 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 30 Aug 2019 09:27:48 -0600 Subject: [PATCH 06/13] corrected deadman t param value --- content/v2.0/reference/flux/functions/monitor/deadman.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/functions/monitor/deadman.md b/content/v2.0/reference/flux/functions/monitor/deadman.md index 08a030398..6f52a49a1 100644 --- a/content/v2.0/reference/flux/functions/monitor/deadman.md +++ b/content/v2.0/reference/flux/functions/monitor/deadman.md @@ -18,7 +18,7 @@ _**Function type:** Transformation_ ```js import "influxdata/influxdb/monitor" -monitor.deadman(t: -3m) +monitor.deadman(t: 2019-08-30T12:30:00Z) ``` `monitor.deadman()` retains the most recent row from each input table and adds a `dead` column. From 5b193f8362a1f748fb9e86652aaf8409847ce720 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 30 Aug 2019 09:37:02 -0600 Subject: [PATCH 07/13] updated monitor.notify endpoint param example --- content/v2.0/reference/flux/functions/monitor/notify.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/functions/monitor/notify.md b/content/v2.0/reference/flux/functions/monitor/notify.md index e596600fd..5f7dfec22 100644 --- a/content/v2.0/reference/flux/functions/monitor/notify.md +++ b/content/v2.0/reference/flux/functions/monitor/notify.md @@ -19,7 +19,7 @@ _**Function type:** Output_ import "influxdata/influxdb/monitor" monitor.notify( - endpoint: , + endpoint: endpoint, data: {} ) ``` From 40b6ef86a2a8947fd3eba8f62fb2f110c1cdc90e Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 30 Aug 2019 16:36:08 -0600 Subject: [PATCH 08/13] added http package, resolves #389 --- .../reference/flux/functions/http/_index.md | 22 +++++++ .../reference/flux/functions/http/post.md | 63 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 content/v2.0/reference/flux/functions/http/_index.md create mode 100644 content/v2.0/reference/flux/functions/http/post.md diff --git a/content/v2.0/reference/flux/functions/http/_index.md b/content/v2.0/reference/flux/functions/http/_index.md new file mode 100644 index 000000000..d8d589f6c --- /dev/null +++ b/content/v2.0/reference/flux/functions/http/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux HTTP package +list_title: HTTP package +description: > + The Flux HTTP package provides functions ... + Import the `http` package. +menu: + v2_0_ref: + name: HTTP + parent: Flux packages and functions +weight: 202 +v2.0/tags: [functions, http, package] +--- + +The Flux HTTP package provides functions ... +Import the `http` package: + +```js +import "http" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/http/post.md b/content/v2.0/reference/flux/functions/http/post.md new file mode 100644 index 000000000..4a143fc39 --- /dev/null +++ b/content/v2.0/reference/flux/functions/http/post.md @@ -0,0 +1,63 @@ +--- +title: http.post() function +description: The `http.post()` function submits an HTTP POST request to the specified URL with headers and data. +// The HTTP status code is returned. +menu: + v2_0_ref: + name: http.post + parent: HTTP +weight: 202 +--- + +The `http.post()` function submits an HTTP POST request to the specified URL with +headers and data and returns the HTTP status code. + +_**Function type:** Output_ + +```js +import "http" + +http.post( + url: "http://localhost:9999/", + headers: {x:"a", y:"b", z:"c"}, + data: bytes(v: "body") +) +``` + +## Parameters + +### url +The URL to POST to. + +_**Data type:** String_ + +### headers +Headers to include with the POST request. + +_**Data type:** Object_ + +### data +The data body to include with the POST request. + +_**Data type:** Bytes_ + +## Examples + +### ... +```js +import "json" +import "http" + +lastReported = + from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses") + |> last() + |> map(fn: (r) => { return {status: r._status} }) + +http.post( + url: "http://myawsomeurl.com/api/notify", + headers: {Authorization: "Bearer mySuPerSecRetTokEn"}, + data: bytes(v: lastReported) +) +``` From ebc0ec00e4799ba60283dd103a694eba7d2452af Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 4 Sep 2019 11:46:03 -0600 Subject: [PATCH 09/13] finished http package, resolves #389 --- .../reference/flux/functions/http/_index.md | 4 +- .../reference/flux/functions/http/endpoint.md | 58 +++++++++++++++++++ .../reference/flux/functions/http/post.md | 7 ++- 3 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 content/v2.0/reference/flux/functions/http/endpoint.md diff --git a/content/v2.0/reference/flux/functions/http/_index.md b/content/v2.0/reference/flux/functions/http/_index.md index d8d589f6c..575108bfb 100644 --- a/content/v2.0/reference/flux/functions/http/_index.md +++ b/content/v2.0/reference/flux/functions/http/_index.md @@ -2,7 +2,7 @@ title: Flux HTTP package list_title: HTTP package description: > - The Flux HTTP package provides functions ... + The Flux HTTP package provides functions for transferring data using the HTTP protocol. Import the `http` package. menu: v2_0_ref: @@ -12,7 +12,7 @@ weight: 202 v2.0/tags: [functions, http, package] --- -The Flux HTTP package provides functions ... +The Flux HTTP package provides functions for transferring data using the HTTP protocol. Import the `http` package: ```js diff --git a/content/v2.0/reference/flux/functions/http/endpoint.md b/content/v2.0/reference/flux/functions/http/endpoint.md new file mode 100644 index 000000000..67e117df5 --- /dev/null +++ b/content/v2.0/reference/flux/functions/http/endpoint.md @@ -0,0 +1,58 @@ +--- +title: http.endpoint() function +description: > + The `http.endpoint()` function sends output data to a an HTTP URL using the POST request method. +menu: + v2_0_ref: + name: http.endpoint + parent: HTTP +weight: 202 +--- + +The `http.endpoint()` function sends output data to a an HTTP URL using the POST request method. + +_**Function type:** Output_ + +```js +import "http" + +http.endpoint( + url: "http://localhost:1234/" +) +``` + +## Parameters + +### url +The URL to POST to. + +_**Data type:** String_ + +### mapFn +A function that builds the object used to generate the POST request. +The object must include `headers` and `data` key-value pairs. +_For more information, see [`http.post()`](/v2.0/reference/flux/functions/http/post/)_ + +{{% 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 +[`http.endpoint()` source code](https://github.com/influxdata/flux/blob/master/stdlib/http/http.flux)._ +{{% /note %}} + +_**Data type:** Function_ + +## Examples + +##### Send critical statuses to an HTTP endpoint +```js +import "monitor" +import "http" + +endpoint = http.endpoint(url: "http://myawsomeurl.com/api/notify") + +from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses" and status == "crit") + |> map(fn: (r) => { return {status: r._status} }) + |> monitor.notify(endpoint: endpoint) +``` diff --git a/content/v2.0/reference/flux/functions/http/post.md b/content/v2.0/reference/flux/functions/http/post.md index 4a143fc39..214c15833 100644 --- a/content/v2.0/reference/flux/functions/http/post.md +++ b/content/v2.0/reference/flux/functions/http/post.md @@ -1,7 +1,8 @@ --- title: http.post() function -description: The `http.post()` function submits an HTTP POST request to the specified URL with headers and data. -// The HTTP status code is returned. +description: > + The `http.post()` function submits an HTTP POST request to the specified URL with headers and data. + The HTTP status code is returned. menu: v2_0_ref: name: http.post @@ -43,7 +44,7 @@ _**Data type:** Bytes_ ## Examples -### ... +##### Send the last reported status to a URL ```js import "json" import "http" From 6f9893a7754974c5cfbe00fcf229e39a438ca998 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 4 Sep 2019 15:33:45 -0600 Subject: [PATCH 10/13] added the flux slack package, resolves #423 --- .../reference/flux/functions/http/endpoint.md | 9 +- .../reference/flux/functions/slack/_index.md | 22 ++++ .../flux/functions/slack/endpoint.md | 84 ++++++++++++ .../reference/flux/functions/slack/message.md | 123 ++++++++++++++++++ 4 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 content/v2.0/reference/flux/functions/slack/_index.md create mode 100644 content/v2.0/reference/flux/functions/slack/endpoint.md create mode 100644 content/v2.0/reference/flux/functions/slack/message.md diff --git a/content/v2.0/reference/flux/functions/http/endpoint.md b/content/v2.0/reference/flux/functions/http/endpoint.md index 67e117df5..b251070d5 100644 --- a/content/v2.0/reference/flux/functions/http/endpoint.md +++ b/content/v2.0/reference/flux/functions/http/endpoint.md @@ -30,8 +30,6 @@ _**Data type:** String_ ### mapFn A function that builds the object used to generate the POST request. -The object must include `headers` and `data` key-value pairs. -_For more information, see [`http.post()`](/v2.0/reference/flux/functions/http/post/)_ {{% note %}} _You should rarely need to override the default `mapFn` parameter. @@ -41,6 +39,13 @@ To see the default `mapFn` value or for insight into possible overrides, view th _**Data type:** Function_ +The returned object must include the following fields: + +- `headers` +- `data` + +_For more information, see [`http.post()`](/v2.0/reference/flux/functions/http/post/)_ + ## Examples ##### Send critical statuses to an HTTP endpoint diff --git a/content/v2.0/reference/flux/functions/slack/_index.md b/content/v2.0/reference/flux/functions/slack/_index.md new file mode 100644 index 000000000..82e48c738 --- /dev/null +++ b/content/v2.0/reference/flux/functions/slack/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux Slack package +list_title: Slack package +description: > + The Flux Slack package provides functions for sending data to Slack. + Import the `slack` package. +menu: + v2_0_ref: + name: Slack + parent: Flux packages and functions +weight: 202 +v2.0/tags: [functions, slack, package] +--- + +The Flux Slack package provides functions for sending data to Slack. +Import the `slack` package: + +```js +import "slack" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/slack/endpoint.md b/content/v2.0/reference/flux/functions/slack/endpoint.md new file mode 100644 index 000000000..bee802fe6 --- /dev/null +++ b/content/v2.0/reference/flux/functions/slack/endpoint.md @@ -0,0 +1,84 @@ +--- +title: slack.endpoint() function +description: > + The `slack.endpoint()` function sends a message to Slack that includes output data. +menu: + v2_0_ref: + name: slack.endpoint + parent: Slack +weight: 202 +--- + +The `slack.endpoint()` function sends a message to Slack that includes output data. + +_**Function type:** Output_ + +```js +import "slack" + +slack.endpoint( + url: "https://slack.com/api/chat.postMessage", + token: "mySuPerSecRetTokEn" +) +``` + +## Parameters + +### url +The Slack API URL. +Defaults to `https://slack.com/api/chat.postMessage`. + +{{% note %}} +If using a Slack Webhook, the Webhook setup process provides the +[Webhook URL](https://api.slack.com/incoming-webhooks#create_a_webhook). +{{% /note %}} + +_**Data type:** String_ + +### token +The Slack API token used to interact with Slack. +Defaults to `""`. + +{{% note %}} +A token is only required if using the Slack chat.postMessage API. +{{% /note %}} + +_**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 +[`slack.endpoint()` source code](https://github.com/influxdata/flux/blob/master/stdlib/slack/slack.flux)._ +{{% /note %}} + +_**Data type:** Function_ + +The returned object must include the following fields: + +- `username` +- `channel` +- `workspace` +- `text` +- `iconEmoji` +- `color` + +_For more information, see [`slack.message()`](/v2.0/reference/flux/functions/slack/message/)_ + +## Examples + +##### Send critical statuses to a Slack endpoint +```js +import "monitor" +import "slack" + +endpoint = slack.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/slack/message.md b/content/v2.0/reference/flux/functions/slack/message.md new file mode 100644 index 000000000..a7a0cfbdf --- /dev/null +++ b/content/v2.0/reference/flux/functions/slack/message.md @@ -0,0 +1,123 @@ +--- +title: slack.message() function +description: > + The `slack.message()` function sends a single message to a Slack channel. + It work with either with the chat.postMessage API or with a Slack webhook. +menu: + v2_0_ref: + name: slack.message + parent: Slack +weight: 202 +--- + +The `slack.message()` function sends a single message to a Slack channel. +It will work either with the [chat.postMessage API](https://api.slack.com/methods/chat.postMessage) +or with a [Slack Webhook](https://api.slack.com/incoming-webhooks). + +_**Function type:** Output_ + +```js +import "slack" + +slack.message( + url: "https://slack.com/api/chat.postMessage", + token: "mySuPerSecRetTokEn", + username: "Fluxtastic", + channel: "#flux", + workspace: "", + text: "This is a message from the Flux slack.message() function.", + iconEmoji: "wave", + color: "good" +) +``` + +## Parameters + +### url +The Slack API URL. +Defaults to `https://slack.com/api/chat.postMessage`. + +{{% note %}} +If using a Slack Webhook, the Webhook setup process provides the +[Webhook URL](https://api.slack.com/incoming-webhooks#create_a_webhook). +{{% /note %}} + +_**Data type:** String_ + +### token +The Slack API token used to interact with Slack. +Defaults to `""`. + +{{% note %}} +A token is only required if using the Slack chat.postMessage API. +{{% /note %}} + +_**Data type:** String_ + +### username +The username to use when posting the message to a Slack channel. Required + +_**Data type:** String_ + +### channel +The name of channel in which to post the message. Required + +_**Data type:** String_ + +### workspace +The name of the Slack workspace to use if there are multiple. +Defaults to `""`. + +_**Data type:** String_ + +### text +The text to display in the Slack message. Required + +_**Data type:** String_ + +### iconEmoji +The name of emoji to use as the user avatar when posting the message to Slack. +Required + +_**Data type:** String_ + +{{% note %}} +#### Things to know about iconEmoji +- **Do not** enclose the name in colons `:` as you do in the Slack client. +- If using a Slack Webhook, the `iconEmoji` **will not** show as the avatar. +{{% /note %}} + +### color +The color to include with the message. +Required + +**Valid values include:** + +- `good` +- `warning` +- `danger` +- Any valid RGB hex color code. For example: `#439FE0`. + +_**Data type:** String_ + +## Examples + +##### Send the last reported status to Slack +```js +import "slack" + +lastReported = + from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses") + |> last() + |> map(fn: (r) => { return {status: r._status} }) + +slack.message( + url: "https://slack.com/api/chat.postMessage", + token: "mySuPerSecRetTokEn", + username: "johndoe", + channel: "#system-status", + text: "The last reported status was \"${lastReported.status}\"." +) +``` From 3cc49e0cc36e687ddf033e7a9a95d4a37cc9b163 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 5 Sep 2019 07:49:22 -0600 Subject: [PATCH 11/13] updated http and slack docs to address PR feedback --- .../reference/flux/functions/http/endpoint.md | 4 ++-- .../flux/functions/slack/endpoint.md | 7 ++++--- .../reference/flux/functions/slack/message.md | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/content/v2.0/reference/flux/functions/http/endpoint.md b/content/v2.0/reference/flux/functions/http/endpoint.md index b251070d5..6b316bf27 100644 --- a/content/v2.0/reference/flux/functions/http/endpoint.md +++ b/content/v2.0/reference/flux/functions/http/endpoint.md @@ -1,7 +1,7 @@ --- title: http.endpoint() function description: > - The `http.endpoint()` function sends output data to a an HTTP URL using the POST request method. + The `http.endpoint()` function sends output data to an HTTP URL using the POST request method. menu: v2_0_ref: name: http.endpoint @@ -9,7 +9,7 @@ menu: weight: 202 --- -The `http.endpoint()` function sends output data to a an HTTP URL using the POST request method. +The `http.endpoint()` function sends output data to an HTTP URL using the POST request method. _**Function type:** Output_ diff --git a/content/v2.0/reference/flux/functions/slack/endpoint.md b/content/v2.0/reference/flux/functions/slack/endpoint.md index bee802fe6..ea3ecbb7a 100644 --- a/content/v2.0/reference/flux/functions/slack/endpoint.md +++ b/content/v2.0/reference/flux/functions/slack/endpoint.md @@ -29,14 +29,15 @@ The Slack API URL. Defaults to `https://slack.com/api/chat.postMessage`. {{% note %}} -If using a Slack Webhook, the Webhook setup process provides the -[Webhook URL](https://api.slack.com/incoming-webhooks#create_a_webhook). +If using a Slack webhook, you'll receive a Slack webhook URL when you +[create an incoming webhook](https://api.slack.com/incoming-webhooks#create_a_webhook). {{% /note %}} _**Data type:** String_ ### token -The Slack API token used to interact with Slack. +The [Slack API token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) +used to interact with Slack. Defaults to `""`. {{% note %}} diff --git a/content/v2.0/reference/flux/functions/slack/message.md b/content/v2.0/reference/flux/functions/slack/message.md index a7a0cfbdf..70606b866 100644 --- a/content/v2.0/reference/flux/functions/slack/message.md +++ b/content/v2.0/reference/flux/functions/slack/message.md @@ -2,7 +2,7 @@ title: slack.message() function description: > The `slack.message()` function sends a single message to a Slack channel. - It work with either with the chat.postMessage API or with a Slack webhook. + The function works with either with the chat.postMessage API or with a Slack webhook. menu: v2_0_ref: name: slack.message @@ -11,8 +11,8 @@ weight: 202 --- The `slack.message()` function sends a single message to a Slack channel. -It will work either with the [chat.postMessage API](https://api.slack.com/methods/chat.postMessage) -or with a [Slack Webhook](https://api.slack.com/incoming-webhooks). +The function works with either with the [chat.postMessage API](https://api.slack.com/methods/chat.postMessage) +or with a [Slack webhook](https://api.slack.com/incoming-webhooks). _**Function type:** Output_ @@ -38,14 +38,15 @@ The Slack API URL. Defaults to `https://slack.com/api/chat.postMessage`. {{% note %}} -If using a Slack Webhook, the Webhook setup process provides the -[Webhook URL](https://api.slack.com/incoming-webhooks#create_a_webhook). +If using a Slack webhook, you'll receive a Slack webhook URL when you +[create an incoming webhook](https://api.slack.com/incoming-webhooks#create_a_webhook). {{% /note %}} _**Data type:** String_ ### token -The Slack API token used to interact with Slack. +The [Slack API token](https://get.slack.help/hc/en-us/articles/215770388-Create-and-regenerate-API-tokens) +used to interact with Slack. Defaults to `""`. {{% note %}} @@ -60,7 +61,7 @@ The username to use when posting the message to a Slack channel. Required +The name of channel to post the message to. Required _**Data type:** String_ @@ -84,7 +85,7 @@ _**Data type:** String_ {{% note %}} #### Things to know about iconEmoji - **Do not** enclose the name in colons `:` as you do in the Slack client. -- If using a Slack Webhook, the `iconEmoji` **will not** show as the avatar. +- `iconEmoji` only appears as the user avatar when using the Slack chat.postMessage API. {{% /note %}} ### color @@ -96,7 +97,7 @@ The color to include with the message. - `good` - `warning` - `danger` -- Any valid RGB hex color code. For example: `#439FE0`. +- Any valid RGB hex color code. For example, `#439FE0`. _**Data type:** String_ From a15b45865be40dbd186dd69933e2d3f8e6fb3ea9 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 5 Sep 2019 08:43:11 -0600 Subject: [PATCH 12/13] added flux secrets package --- .../flux/functions/secrets/_index.md | 22 ++++++++++ .../reference/flux/functions/secrets/get.md | 44 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 content/v2.0/reference/flux/functions/secrets/_index.md create mode 100644 content/v2.0/reference/flux/functions/secrets/get.md diff --git a/content/v2.0/reference/flux/functions/secrets/_index.md b/content/v2.0/reference/flux/functions/secrets/_index.md new file mode 100644 index 000000000..d27834ccf --- /dev/null +++ b/content/v2.0/reference/flux/functions/secrets/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux InfluxDB Secrets package +list_title: InfluxDB Secrets package +description: > + The Flux InfluxDB Secrets package provides functions for working with sensitive secrets managed by InfluxDB. + Import the `influxdata/influxdb/secrets` package. +menu: + v2_0_ref: + name: InfluxDB Secrets + parent: Flux packages and functions +weight: 202 +v2.0/tags: [functions, secrets, package] +--- + +InfluxDB Secrets Flux functions provide tools for working with sensitive secrets managed by InfluxDB. +Import the `influxdata/influxdb/secrets` package: + +```js +import "influxdata/influxdb/secrets" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/secrets/get.md b/content/v2.0/reference/flux/functions/secrets/get.md new file mode 100644 index 000000000..ff669f891 --- /dev/null +++ b/content/v2.0/reference/flux/functions/secrets/get.md @@ -0,0 +1,44 @@ +--- +title: secrets.get() function +description: > + The `secrets.get()` function retrieves a secret from the InfluxDB secret store. +menu: + v2_0_ref: + name: secrets.get + parent: InfluxDB Secrets +weight: 202 +--- + +The `secrets.get()` function retrieves a secret from the InfluxDB secret store. + +_**Function type:** Miscellaneous_ + +```js +import "influxdata/influxdb/secrets" + +secrets.get(key: "KEY_NAME") +``` + +## Parameters + +### key +The secret key to retrieve. + +_**Data type:** String_ + +## Examples + +### Populate sensitive credentials with secrets +```js +import "sql" +import "influxdata/influxdb/secrets" + +username = secrets.get(key: "POSTGRES_USERNAME") +password = secrets.get(key: "POSTGRES_PASSWORD") + +sql.from( + driverName: "postgres", + dataSourceName: "postgresql://${username}:${password}@localhost", + query:"SELECT * FROM example-table" +) +``` From 5c5562db645f32066f1c23068589f0aa47071a4d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 5 Sep 2019 11:05:21 -0600 Subject: [PATCH 13/13] updated flux changelog with 0.41.0 --- content/v2.0/reference/release-notes/flux.md | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/content/v2.0/reference/release-notes/flux.md b/content/v2.0/reference/release-notes/flux.md index 5d7e5d90c..c241a7cc4 100644 --- a/content/v2.0/reference/release-notes/flux.md +++ b/content/v2.0/reference/release-notes/flux.md @@ -11,13 +11,34 @@ aliases: --- {{% note %}} -_The latest release of InfluxDB v2.0 alpha includes **Flux v0.40.2**. +_The latest release of InfluxDB v2.0 alpha includes **Flux v0.41.0**. Though newer versions of Flux may be available, they will not be included with InfluxDB until the next InfluxDB v2.0 release._ {{% /note %}} --- +## v0.41.0 [2019-08-26] + +### Features +- Add ability to validate URLs before making `http.post` requests. +- Evaluate string interpolation. +- Implement the `secrets.get` function. +- Added secret service interface. +- Add secrets package that will construct a secret object. +- Added a SecretService interface and a new dependencies package and a basic test of functionality. +- Add Slack endpoint. + +### Bug fixes +- Make `reset()` check for non-nil data before calling `Release()`. +- Add test case for `notify` function. +- Add missing math import to test case. +- Make packages aware of options. +- Resolved `holtWinters` panic. +- Use non-pointer receiver for `interpreter.function`. + +--- + ## v0.40.2 [2019-08-22] ### Bug fixes