From 31e669f5903dd232d0632de0e83754b25f89279b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 27 Aug 2019 14:27:51 -0600 Subject: [PATCH] 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) ```