Auto-generated Flux docs (#4158)

* WIP testing autogen

* WIP autogen docs, added contributors parital

* updated stdlib

* WIP autogen

* Inject Flux stdlib frontmatter script (#4157)

* added frontmatter injection script and frontmatter data file

* regenerated stdlib

* finalize frontmatter injection script

* add frontmatter injection to CI build

* remove debug line from frontmatter script

* fresh docs generate

* fresh generate
pull/4118/head^2
Scott Anderson 2022-06-23 16:21:58 -06:00 committed by GitHub
parent 12305352fd
commit 909980c765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
607 changed files with 46443 additions and 21120 deletions

View File

@ -29,7 +29,10 @@ jobs:
command: cd api-docs && yarn install
- run:
name: Generate API documentation
command: cd api-docs && bash generate-api-docs.sh
command: cd api-docs && bash generate-api-docs.sh
- run:
name: Inject Flux stdlib frontmatter
command: node ./inject-flux-stdlib-frontmatter.js
- save_cache:
key: install-{{ .Environment.CACHE_VERSION }}-{{ checksum ".circleci/config.yml" }}
paths:

View File

@ -204,7 +204,7 @@ $('.tooltip').each( function(){
$('.article--content table').each(function() {
var table = $(this);
var timeColumns = ['_time', '_start', '_stop'];
var timeColumns = ['_time', '*_time', '_start', '*_start', '_stop', '*_stop'];
let header = [];
let timeColumnIndexes = [];

View File

@ -15,6 +15,7 @@ flux/v0.x/tags: [flux, functions, package]
menu:
flux_0_x_ref:
name: Standard library
identifier: stdlib
weight: 1
---

View File

@ -8,7 +8,7 @@ aliases:
menu:
flux_0_x_ref:
name: View all functions
parent: Standard library
parent: stdlib
weight: 9
---

View File

@ -1,32 +1,44 @@
---
title: Flux array package
list_title: array package
title: array package
description: >
The Flux `array` package provides functions for building tables from Flux arrays.
Import the `array` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/experimental/array/
- /influxdb/cloud/reference/flux/stdlib/experimental/array/
- /influxdb/v2.0/reference/flux/stdlib/array/
- /influxdb/cloud/reference/flux/stdlib/array/
The `array` package provides functions for building tables from Flux arrays.
menu:
flux_0_x_ref:
name: array
parent: Standard library
name: array
parent: stdlib
identifier: array
weight: 11
flux/v0.x/tags: [functions, array, package, table]
cascade:
related:
- /flux/v0.x/data-types/composite/array/
introduced: 0.103.0
flux/v0.x/tags: [array, tables]
introduced: 0.103.0
---
Flux `array` functions provide tools for building tables from Flux arrays.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/array/array.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `array` package provides functions for building tables from Flux arrays.
Import the `array` package:
```js
import "array"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,47 +1,61 @@
---
title: array.from() function
description: >
The experimental `array.from()` function constructs a table from an array of records.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/array/from/
- /influxdb/cloud/reference/flux/stdlib/array/from/
- /influxdb/v2.0/reference/flux/stdlib/experimental/array/from/
- /influxdb/cloud/reference/flux/stdlib/experimental/array/from/
- /flux/v0.x/stdlib/experimental/array/from/
`array.from()` constructs a table from an array of records.
menu:
flux_0_x_ref:
name: array.from
parent: array
weight: 401
identifier: array/from
weight: 101
flux/v0.x/tags: [inputs]
introduced: 0.103.0
---
The `array.from()` function constructs a table from an array of records.
Each record in the array is converted into an output row or record.
All records must have the same keys and data types.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/array/array.flux#L48-L48
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`array.from()` constructs a table from an array of records.
Each record in the array is converted into an output row or record. All
records must have the same keys and data types.
##### Function type signature
{{< keep-url >}}
```js
import "array"
array.from(
rows: [
{_time: 2020-01-01T00:00:00Z, _field: "exampleField", _value: 3, foo: "bar"},
{_time: 2020-01-01T00:01:00Z, _field: "exampleField", _value: 4, foo: "bar"},
{_time: 2020-01-01T00:02:00Z, _field: "exampleField", _value: 1, foo: "bar"},
],
)
(rows: [A]) => stream[A] where A: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### rows {data-type="array"}
### rows
({{< req >}})
Array of records to construct a table with.
## Examples
##### Build an arbitrary table
- [Build an arbitrary table](#build-an-arbitrary-table)
- [Union custom rows with query results](#union-custom-rows-with-query-results)
### Build an arbitrary table
```js
import "array"
@ -50,14 +64,29 @@ rows = [{foo: "bar", baz: 21.2}, {foo: "bar", baz: 23.8}]
array.from(rows: rows)
```
##### Union custom rows with query results
{{< expand-wrapper >}}
{{% expand "View example output" %}}
#### Output data
| foo | baz |
| ---- | ---- |
| bar | 21.2 |
| bar | 23.8 |
{{% /expand %}}
{{< /expand-wrapper >}}
### Union custom rows with query results
```js
import "influxdata/influxdb/v1"
import "array"
tags = v1.tagValues(bucket: "example-bucket", tag: "host")
wildcard_tag = array.from(rows: [{_value: "*"}])
union(tables: [tags, wildcard_tag])
```

View File

@ -0,0 +1,36 @@
---
title: RohanSreerama5 package
description: >
The `RohanSreerama5` package contains packages and functions contributed by [@RohanSreerama5](https://github.com/RohanSreerama5).
menu:
flux_0_x_ref:
name: RohanSreerama5
parent: contrib
identifier: contrib/RohanSreerama5
weight: 21
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/RohanSreerama5/RohanSreerama5.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `RohanSreerama5` package contains packages and functions contributed by [@RohanSreerama5](https://github.com/RohanSreerama5).
## Packages
{{< children show="sections" >}}

View File

@ -0,0 +1,49 @@
---
title: naiveBayesClassifier package
description: >
The `naiveBayesClassifier` package provides an implementation of
a naive Bayes classifier.
menu:
flux_0_x_ref:
name: naiveBayesClassifier
parent: contrib/RohanSreerama5
identifier: contrib/RohanSreerama5/naiveBayesClassifier
weight: 31
cascade:
introduced: v0.86.0
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naiveBayesClassifier.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `naiveBayesClassifier` package provides an implementation of
a naive Bayes classifier.
Import the `contrib/RohanSreerama5/naiveBayesClassifier` package:
```js
import "contrib/RohanSreerama5/naiveBayesClassifier"
```
Currently supports single field classification and binary data sets.
For information about demonstrating functions in this package, see the
[package README on GitHub](https://github.com/influxdata/flux/blob/master/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/README.md).
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,72 @@
---
title: naiveBayesClassifier.naiveBayes() function
description: >
`naiveBayesClassifier.naiveBayes()` performs a naive Bayes classification.
menu:
flux_0_x_ref:
name: naiveBayesClassifier.naiveBayes
parent: contrib/RohanSreerama5/naiveBayesClassifier
identifier: contrib/RohanSreerama5/naiveBayesClassifier/naiveBayes
weight: 301
flux/v0.x/tags: [transformations]
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naiveBayesClassifier.flux#L29-L108
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`naiveBayesClassifier.naiveBayes()` performs a naive Bayes classification.
##### Function type signature
```js
(
<-tables: stream[{C with _time: time, _measurement: E, _field: D}],
myClass: string,
myField: A,
myMeasurement: B,
) => stream[F] where A: Equatable, B: Equatable, D: Equatable, E: Equatable, F: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### myMeasurement
({{< req >}})
Measurement to use as training data.
### myField
({{< req >}})
Field to use as training data.
### myClass
({{< req >}})
Class to classify against.
### tables
Input data. Default is piped-forward data (`<-`).

View File

@ -1,22 +1,33 @@
---
title: Flux contrib package (user-contributed)
list_title: contrib package (user-contributed)
title: contrib package
description: >
The Flux `contrib` package contains packages and functions that are contributed
and maintained by members of the Flux and InfluxDB communities.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/
- /influxdb/cloud/reference/flux/stdlib/contrib/
The `contrib` package contains packages and functions contributed and maintained by members of the Flux and InfluxDB communities.
menu:
flux_0_x_ref:
name: contrib
parent: Standard library
name: contrib
parent: stdlib
identifier: contrib
weight: 11
flux/v0.x/tags: [contributed, functions, package]
---
The Flux `contrib` package contains packages and functions that are contributed
and maintained by members of the Flux and InfluxDB communities.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/contrib.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `contrib` package contains packages and functions contributed and maintained by members of the Flux and InfluxDB communities.
InfluxData supports user-contributed Flux packages and functions.
We also recognize the importance of original contributors reviewing updates to
their packages and functions.
@ -27,4 +38,7 @@ original authors on all proposed changes to contributed packages and functions.
For information about adding a new Flux package or future plans regarding Flux contributions,
see [Contribute Third Party Flux Packages](https://github.com/influxdata/flux/blob/master/stdlib/contrib/README.md).
{{< children >}}
## Packages
{{< children show="sections" >}}

View File

@ -0,0 +1,36 @@
---
title: anaisdg package
description: >
The `anaisdg` package contains packages and functions contributed by [@anaisdg](https://github.com/anaisdg).
menu:
flux_0_x_ref:
name: anaisdg
parent: contrib
identifier: contrib/anaisdg
weight: 21
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/anaisdg/anaisdg.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `anaisdg` package contains packages and functions contributed by [@anaisdg](https://github.com/anaisdg).
## Packages
{{< children show="sections" >}}

View File

@ -0,0 +1,41 @@
---
title: anomalydetection package
description: >
The `anomalydetection` package detects anomalies in time series data.
menu:
flux_0_x_ref:
name: anomalydetection
parent: contrib/anaisdg
identifier: contrib/anaisdg/anomalydetection
weight: 31
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/anaisdg/anomalydetection/anomalydetection.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `anomalydetection` package detects anomalies in time series data.
Import the `contrib/anaisdg/anomalydetection` package:
```js
import "contrib/anaisdg/anomalydetection"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,131 @@
---
title: anomalydetection.mad() function
description: >
`anomalydetection.mad()` uses the median absolute deviation (MAD) algorithm to detect anomalies in a data set.
menu:
flux_0_x_ref:
name: anomalydetection.mad
parent: contrib/anaisdg/anomalydetection
identifier: contrib/anaisdg/anomalydetection/mad
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/anaisdg/anomalydetection/mad.flux#L33-L68
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`anomalydetection.mad()` uses the median absolute deviation (MAD) algorithm to detect anomalies in a data set.
Input data requires `_time` and `_value` columns.
Output data is grouped by `_time` and includes the following columns of interest:
- **\_value**: difference between of the original `_value` from the computed MAD
divided by the median difference.
- **MAD**: median absolute deviation of the group.
- **level**: anomaly indicator set to either `anomaly` or `normal`.
##### Function type signature
```js
(<-table: stream[B], ?threshold: A) => stream[{C with level: string, _value_diff_med: D, _value_diff: D, _value: D}] where A: Comparable + Equatable, B: Record, D: Comparable + Divisible + Equatable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### threshold
Deviation threshold for anomalies.
### table
Input data. Default is piped-forward data (`<-`).
## Examples
### Use the MAD algorithm to detect anomalies
```js
import "contrib/anaisdg/anomalydetection"
import "sampledata"
sampledata.float()
|> anomalydetection.mad(threshold: 1.0)
```
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
#### Input data
| _time | *tag | _value |
| -------------------- | ---- | ------- |
| 2021-01-01T00:00:00Z | t1 | -2.18 |
| 2021-01-01T00:00:10Z | t1 | 10.92 |
| 2021-01-01T00:00:20Z | t1 | 7.35 |
| 2021-01-01T00:00:30Z | t1 | 17.53 |
| 2021-01-01T00:00:40Z | t1 | 15.23 |
| 2021-01-01T00:00:50Z | t1 | 4.43 |
| _time | *tag | _value |
| -------------------- | ---- | ------- |
| 2021-01-01T00:00:00Z | t2 | 19.85 |
| 2021-01-01T00:00:10Z | t2 | 4.97 |
| 2021-01-01T00:00:20Z | t2 | -3.75 |
| 2021-01-01T00:00:30Z | t2 | 19.77 |
| 2021-01-01T00:00:40Z | t2 | 13.86 |
| 2021-01-01T00:00:50Z | t2 | 1.86 |
#### Output data
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| --------- | -------------------- | ------- | ------------ | ---------------- | ------- | ---- |
| 16.330839 | 2021-01-01T00:00:00Z | 1 | 11.015 | 11.015 | anomaly | t1 |
| 16.330839 | 2021-01-01T00:00:00Z | 1 | 11.015 | 11.015 | anomaly | t2 |
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| -------- | -------------------- | ------------------ | ------------------ | ---------------- | ------- | ---- |
| 4.410735 | 2021-01-01T00:00:10Z | 0.9999999999999999 | 2.9749999999999996 | 2.975 | normal | t1 |
| 4.410735 | 2021-01-01T00:00:10Z | 1.0000000000000002 | 2.9750000000000005 | 2.975 | anomaly | t2 |
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| ------- | -------------------- | ------- | ------------ | ---------------- | ------- | ---- |
| 8.22843 | 2021-01-01T00:00:20Z | 1 | 5.55 | 5.55 | anomaly | t1 |
| 8.22843 | 2021-01-01T00:00:20Z | 1 | 5.55 | 5.55 | anomaly | t2 |
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| ------------------ | -------------------- | ------------------ | ------------------ | ------------------ | ------- | ---- |
| 1.6605119999999987 | 2021-01-01T00:00:30Z | 0.9999999999999984 | 1.1199999999999974 | 1.1199999999999992 | normal | t1 |
| 1.6605119999999987 | 2021-01-01T00:00:30Z | 1.0000000000000016 | 1.120000000000001 | 1.1199999999999992 | anomaly | t2 |
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| ------------------ | -------------------- | ------- | ------------------ | ------------------ | ------- | ---- |
| 1.0155810000000007 | 2021-01-01T00:00:40Z | 1 | 0.6850000000000005 | 0.6850000000000005 | anomaly | t1 |
| 1.0155810000000007 | 2021-01-01T00:00:40Z | 1 | 0.6850000000000005 | 0.6850000000000005 | anomaly | t2 |
| MAD | *_time | _value | _value_diff | _value_diff_med | level | tag |
| ------------------ | -------------------- | ------------------ | ------------------ | ------------------ | ------- | ---- |
| 1.9051409999999995 | 2021-01-01T00:00:50Z | 1 | 1.2849999999999997 | 1.2849999999999997 | anomaly | t1 |
| 1.9051409999999995 | 2021-01-01T00:00:50Z | 1.0000000000000002 | 1.285 | 1.2849999999999997 | anomaly | t2 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -0,0 +1,41 @@
---
title: statsmodels package
description: >
The `statsmodels` package provides functions for calculating statistical models.
menu:
flux_0_x_ref:
name: statsmodels
parent: contrib/anaisdg
identifier: contrib/anaisdg/statsmodels
weight: 31
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/anaisdg/statsmodels/statsmodels.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `statsmodels` package provides functions for calculating statistical models.
Import the `contrib/anaisdg/statsmodels` package:
```js
import "contrib/anaisdg/statsmodels"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,89 @@
---
title: statsmodels.linearRegression() function
description: >
`statsmodels.linearRegression()` performs a linear regression.
menu:
flux_0_x_ref:
name: statsmodels.linearRegression
parent: contrib/anaisdg/statsmodels
identifier: contrib/anaisdg/statsmodels/linearRegression
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/anaisdg/statsmodels/linearreg.flux#L40-L88
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`statsmodels.linearRegression()` performs a linear regression.
It calculates and returns [*ŷ*](https://en.wikipedia.org/wiki/Hat_operator#Estimated_value) (`y_hat`),
and [residual sum of errors](https://en.wikipedia.org/wiki/Residual_sum_of_squares) (`rse`).
Output data includes the following columns:
- **N**: Number of points in the calculation.
- **slope**: Slope of the calculated regression.
- **sx**: Sum of x.
- **sxx**: Sum of x squared.
- **sxy**: Sum of x*y.
- **sy**: Sum of y.
- **errors**: Residual sum of squares.
Defined by `(r.y - r.y_hat) ^ 2` in this context
- **x**: An index [1,2,3,4...n], with the assumption that the timestamps are regularly spaced.
- **y**: Field value
- **y\_hat**: Linear regression values
##### Function type signature
```js
(
<-tables: stream[A],
) => stream[{
B with
y_hat: float,
y: float,
x: float,
sy: H,
sxy: G,
sxx: F,
sx: E,
slope: D,
errors: float,
N: C,
}] where A: Record, D: Divisible + Subtractable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### tables
Input data. Default is piped-forward data (`<-`).
## Examples
### Perform a linear regression on a dataset
```js
import "contrib/anaisdg/statsmodels"
import "sampledata"
sampledata.float()
|> statsmodels.linearRegression()
```

View File

@ -1,26 +1,36 @@
---
title: Packages contributed by bonitoo-io
list_title: bonitoo-io package
title: bonitoo-io package
description: >
The `bonitoo-io` package contains functions and packages contributed by
[@bonitoo-io](https://github.com/bonitoo-io).
The `bonitoo-io` package contains packages and functions contributed by [@bonitoo-io](https://github.com/bonitoo-io).
menu:
flux_0_x_ref:
name: bonitoo-io
name: bonitoo-io
parent: contrib
weight: 101
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io)
**InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack)
identifier: contrib/bonitoo-io
weight: 21
---
The `bonitoo-io` package contains functions and packages contributed by
[@bonitoo-io](https://github.com/bonitoo-io).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/bonitoo-io.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `bonitoo-io` package contains packages and functions contributed by [@bonitoo-io](https://github.com/bonitoo-io).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -1,35 +1,44 @@
---
title: Flux alerta package
list_title: alerta package
title: alerta package
description: >
The Flux `alerta` package provides functions that send alerts to
[Alerta](https://alerta.io/).
The `alerta` package provides functions that send alerts to [Alerta](https://alerta.io/).
menu:
flux_0_x_ref:
name: alerta
parent: bonitoo-io
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/
- /influxdb/cloud/reference/flux/stdlib/contrib/alerta/
flux/v0.x/tags: [functions, alerta, package]
introduced: 0.115.0
name: alerta
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/alerta
weight: 31
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@alespour](https://github.com/alespour), [@bonitoo-io](https://github.com/bonitoo-io)
**InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack)
introduced: 0.115.0
---
The Flux `alerta` package provides functions that send alerts to
[Alerta](https://alerta.io/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/alerta/alerta.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `alerta` package provides functions that send alerts to [Alerta](https://alerta.io/).
Import the `contrib/bonitoo-io/alerta` package:
```js
import "contrib/bonitoo-io/alerta"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,114 +1,157 @@
---
title: alerta.alert() function
description: >
The `alerta.alert()` function sends an alert to Alerta.
`alerta.alert()` sends an alert to [Alerta](https://alerta.io/).
menu:
flux_0_x_ref:
name: alerta.alert
parent: alerta
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/alert/
- /influxdb/cloud/reference/flux/stdlib/contrib/alerta/alert/
introduced: 0.115.0
parent: contrib/bonitoo-io/alerta
identifier: contrib/bonitoo-io/alerta/alert
weight: 301
flux/v0.x/tags: [single notification]
---
The `alerta.alert()` function sends an alert to [Alerta](https://www.alerta.io/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/alerta/alerta.flux#L74-L113
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`alerta.alert()` sends an alert to [Alerta](https://alerta.io/).
##### Function type signature
```js
import "contrib/bonitoo-io/alerta"
alerta.alert(
url: "https://alerta.io:8080/alert",
apiKey: "0Xx00xxXx00Xxx0x0X",
resource: "example-resource",
event: "Example event",
environment: "",
severity: "critical",
service: [],
group: "",
value: "",
text: "",
tags: [],
attributes: {},
origin: "InfluxDB",
type: "",
timestamp: now(),
)
(
apiKey: string,
attributes: A,
event: B,
resource: C,
severity: D,
url: string,
?environment: E,
?group: F,
?origin: G,
?service: H,
?tags: I,
?text: J,
?timestamp: t10,
?type: t11,
?value: t12,
) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Alerta URL.
(Required) Alerta URL.
### apiKey {data-type="string"}
### apiKey
({{< req >}})
Alerta API key.
(Required) Alerta API key.
### resource {data-type="string"}
### resource
({{< req >}})
Resource associated with the alert.
(Required) Resource associated with the alert.
### event {data-type="string"}
### event
({{< req >}})
Event name.
(Required) Event name.
### environment {data-type="string"}
Alert environment.
Default is `""`.
**Valid values:**
- `""`
- `"Production"`
- `"Development"`
### environment
### severity {data-type="string"}
Alerta environment. Valid values: "Production", "Development" or empty string (default).
### severity
({{< req >}})
Event severity.
See [Alerta severities](https://docs.alerta.io/en/latest/api/alert.html#alert-severities).
(Required) Event severity. See [Alerta severities](https://docs.alerta.io/en/latest/api/alert.html#alert-severities).
### service {data-type="array of strings"}
List of affected services.
Default is `[]`.
### group {data-type="string"}
Alerta event group.
Default is `""`.
### value {data-type="string"}
Event value.
Default is `""`.
### service
### text {data-type="string"}
Alert text description.
Default is `""`.
List of affected services. Default is `[]`.
### tags {data-type="array of strings"}
List of event tags.
Default is `[]`.
### attributes {data-type="record"}
### group
Alerta event group. Default is `""`.
### value
Event value. Default is `""`.
### text
Alerta text description. Default is `""`.
### tags
List of event tags. Default is `[]`.
### attributes
({{< req >}})
Alert attributes.
(Required) Alert attributes.
### origin
monitoring component.
### type
Event type. Default is `""`.
### timestamp
time alert was generated. Default is `now()`.
### origin {data-type="string"}
Alert origin.
Default is `"InfluxDB"`.
### type {data-type="string"}
Event type.
Default is `""`.
### timestamp {data-type="time"}
time alert was generated.
Default is `now()`.
## Examples
##### Send the last reported value and status to Alerta
### Send the last reported value and status to Alerta
```js
import "contrib/bonitoo-io/alerta"
import "influxdata/influxdb/secrets"
@ -142,3 +185,4 @@ alerta.alert(
timestamp: now(),
)
```

View File

@ -1,116 +1,89 @@
---
title: alerta.endpoint() function
description: >
The `alerta.endpoint()` function sends alerts to Alerta using data from input rows.
`alerta.endpoint()` sends alerts to Alerta using data from input rows.
menu:
flux_0_x_ref:
name: alerta.endpoint
parent: alerta
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/alerta/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/alerta/endpoint/
flux/v0.x/tags: [notification endpoints]
introduced: 0.115.0
parent: contrib/bonitoo-io/alerta
identifier: contrib/bonitoo-io/alerta/endpoint
weight: 301
---
The `alerta.endpoint()` function sends alerts to [Alerta](https://alerta.io/)
using data from input rows.
<!------------------------------------------------------------------------------
_**Function type:** Output_
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/alerta/alerta.flux#L189-L220
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`alerta.endpoint()` sends alerts to Alerta using data from input rows.
##### Function type signature
```js
import "contrib/bonitoo-io/alerta"
alerta.endpoint(
url: "https://alerta.io:8080/alert",
apiKey: "0Xx00xxXx00Xxx0x0X",
environment: "",
origin: "InfluxDB"
)
(
apiKey: string,
url: string,
?environment: A,
?origin: B,
) => (
mapFn: (
r: C,
) => {
D with
value: t14,
type: t13,
timestamp: t12,
text: t11,
tags: t10,
severity: J,
service: I,
resource: H,
group: G,
event: F,
attributes: E,
},
) => (<-tables: stream[C]) => stream[{C with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Alerta URL.
(Required) Alerta URL.
### apiKey {data-type="string"}
### apiKey
({{< req >}})
Alerta API key.
(Required) Alerta API key.
### environment {data-type="string"}
Alert environment.
Default is `""`.
**Valid values:**
- `""`
- `"Production"`
- `"Development"`
### environment
### origin {data-type="string"}
Alert origin.
Default is `"InfluxDB"`.
Alert environment. Default is `""`.
Valid values: "Production", "Development" or empty string (default).
## Usage
`alerta.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
### origin
- `resource`
- `event`
- `severity`
- `service`
- `group`
- `value`
- `text`
- `tags`
- `attributes`
- `type`
- `timestamp`
Alert origin. Default is `"InfluxDB"`.
_For more information, see [`alerta.alert()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/alerta/alert/#parameters)._
## Examples
##### Send critical alerts to Alerta
```js
import "contrib/bonitoo-io/alerta"
import "influxdata/influxdb/secrets"
apiKey = secrets.get(key: "ALERTA_API_KEY")
endpoint =
alerta.endpoint(url: "https://alerta.io:8080/alert", apiKey: apiKey, environment: "Production", origin: "InfluxDB")
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) => {
return {r with
resource: "example-resource",
event: "example-event",
severity: "critical",
service: r.service,
group: "example-group",
value: r.status,
text: "Status is critical.",
tags: ["ex1", "ex2"],
attributes: {},
type: "exampleAlertType",
timestamp: now(),
}
},
)()
```

View File

@ -1,31 +1,46 @@
---
title: Flux hex package
list_title: hex package
title: hex package
description: >
The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types.
Import the `contrib/bonitoo-io/hex` package.
The `hex` package provides functions that perform hexadecimal conversion
of `int`, `uint` or `bytes` values to and from `string` values.
menu:
flux_0_x_ref:
name: hex
parent: bonitoo-io
weight: 202
flux/v0.x/tags: [functions, hex, package]
name: hex
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/hex
weight: 31
cascade:
introduced: 0.131.0
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@bonitoo-io](https://github.com/bonitoo-io), [@sranka](https://github.com/sranka)
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
---
The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types.
Import the `contrib/bonitoo-io/hex` package.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/hex/hex.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `hex` package provides functions that perform hexadecimal conversion
of `int`, `uint` or `bytes` values to and from `string` values.
Import the `contrib/bonitoo-io/hex` package:
```js
import "contrib/bonitoo-io/hex"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -5,35 +5,57 @@ description: >
menu:
flux_0_x_ref:
name: hex.bytes
parent: hex
weight: 302
related:
- /flux/v0.x/data-types/basic/bytes/
flux/v0.x/tags: [type-conversions]
parent: contrib/bonitoo-io/hex
identifier: contrib/bonitoo-io/hex/bytes
weight: 301
---
`hex.bytes()` decodes a hexadecimal string and converts the decoded value to bytes.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/hex/hex.flux#L169-L169
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`hex.bytes()` converts a hexadecimal string to bytes.
##### Function type signature
```js
import "contrib/bonitoo-io/hex"
hex.bytes(v: "6869")
// Returns [104 105] (the bytes representation of "hi")
(v: string) => bytes
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v {data-type="string"}
Value to convert.
### v
({{< req >}})
String to convert.
## Examples
#### Convert a hexadecimal string to bytes
### Convert a hexadecimal string into bytes
```js
import "contrib/bonitoo-io/hex"
hex.bytes(v: "FF5733")
hex.bytes(v: "FF5733")// Returns [255 87 51] (bytes)
```
// Returns [255 87 51] (bytes)
```

View File

@ -1,109 +1,61 @@
---
title: hex.int() function
description: >
`hex.int()` converts a hexadecimal string representation of a number to an integer.
`hex.int()` converts a hexadecimal string to an integer.
menu:
flux_0_x_ref:
name: hex.int
parent: hex
weight: 302
related:
- /flux/v0.x/data-types/basic/int/
flux/v0.x/tags: [type-conversions]
parent: contrib/bonitoo-io/hex
identifier: contrib/bonitoo-io/hex/int
weight: 301
---
`hex.int()` converts a hexadecimal string representation of a number to an integer.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/hex/hex.flux#L27-L27
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`hex.int()` converts a hexadecimal string to an integer.
##### Function type signature
```js
import "contrib/bonitoo-io/hex"
hex.int(v: "4d2")
// Returns 1234
(v: string) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v {data-type="string"}
Value to convert.
### v
({{< req >}})
String to convert.
## Examples
- [Convert a hexadecimal string to an integer](#convert-a-hexadecimal-string-to-an-integer)
- [Convert all hexadecimal string values in a column to integers](#convert-all-hexadecimal-string-values-in-a-column-to-integers)
### Convert hexadecimal string to integer
#### Convert a hexadecimal string to an integer
```js
import "contrib/bonitoo-io/hex"
hex.int(v: "-d431")
hex.int(v: "4d2")// Returns 1234
// Returns -54321
```
#### Convert all hexadecimal string values in a column to integers
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
2. Use `hex.int()` to update the value of a column.
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
```js
import "sampledata"
data =
sampledata.int()
|> map(fn: (r) => ({r with _value: hex.string(v: r._value)}))
data
|> map(fn: (r) => ({r with _value: hex.int(v: r._value)}))
```
{{< expand-wrapper >}}
{{% expand "View input and output" %}}
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | -------------------------------------------------: |
| 2021-01-01T00:00:00Z | t1 | -2 |
| 2021-01-01T00:00:10Z | t1 | a |
| 2021-01-01T00:00:20Z | t1 | 7 |
| 2021-01-01T00:00:30Z | t1 | 11 |
| 2021-01-01T00:00:40Z | t1 | f |
| 2021-01-01T00:00:50Z | t1 | 4 |
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | -------------------------------------------------: |
| 2021-01-01T00:00:00Z | t2 | 13 |
| 2021-01-01T00:00:10Z | t2 | 4 |
| 2021-01-01T00:00:20Z | t2 | -3 |
| 2021-01-01T00:00:30Z | t2 | 13 |
| 2021-01-01T00:00:40Z | t2 | d |
| 2021-01-01T00:00:50Z | t2 | 1 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
| :-- | :------------------- | ----------------------------------------------: |
| t1 | 2021-01-01T00:00:00Z | -2 |
| t1 | 2021-01-01T00:00:10Z | 10 |
| t1 | 2021-01-01T00:00:20Z | 7 |
| t1 | 2021-01-01T00:00:30Z | 17 |
| t1 | 2021-01-01T00:00:40Z | 15 |
| t1 | 2021-01-01T00:00:50Z | 4 |
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
| :-- | :------------------- | ----------------------------------------------: |
| t2 | 2021-01-01T00:00:00Z | 19 |
| t2 | 2021-01-01T00:00:10Z | 4 |
| t2 | 2021-01-01T00:00:20Z | -3 |
| t2 | 2021-01-01T00:00:30Z | 19 |
| t2 | 2021-01-01T00:00:40Z | 13 |
| t2 | 2021-01-01T00:00:50Z | 1 |
{{% /flex-content %}}
{{< /flex >}}
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,36 +1,57 @@
---
title: hex.string() function
description: >
`hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string.
`hex.string()` converts a Flux basic type to a hexadecimal string.
menu:
flux_0_x_ref:
name: hex.string
parent: hex
weight: 302
related:
- /flux/v0.x/stdlib/universe/string/
flux/v0.x/tags: [type-conversions]
parent: contrib/bonitoo-io/hex
identifier: contrib/bonitoo-io/hex/string
weight: 301
---
`hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string.
The function is similar to [string()](/flux/v0.x/stdlib/universe/string/),
but encodes **int, uint, and bytes types** to hexadecimal lowercase characters.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/hex/hex.flux#L129-L129
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`hex.string()` converts a Flux basic type to a hexadecimal string.
The function is similar to `string()`, but encodes int, uint, and bytes
types to hexadecimal lowercase characters.
##### Function type signature
```js
import "contrib/bonitoo-io/hex"
hex.string(v: 1234)
// Returns 4d2
(v: A) => string
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v {data-type="bool, int, uint, float, duration, time, bytes"}
### v
({{< req >}})
Value to convert.
## Examples
- [Convert integer to hexadecimal string](#convert-integer-to-hexadecimal-string)
- [Convert a boolean to a hexadecimal string value](#convert-a-boolean-to-a-hexadecimal-string-value)
- [Convert a duration to a hexadecimal string value](#convert-a-duration-to-a-hexadecimal-string-value)
- [Convert a time to a hexadecimal string value](#convert-a-time-to-a-hexadecimal-string-value)
@ -40,75 +61,91 @@ Value to convert.
- [Convert bytes to a hexadecimal string value](#convert-bytes-to-a-hexadecimal-string-value)
- [Convert all values in a column to hexadecimal string values](#convert-all-values-in-a-column-to-hexadecimal-string-values)
#### Convert a boolean to a hexadecimal string value
### Convert integer to hexadecimal string
```js
import "contrib/bonitoo-io/hex"
hex.string(v: true)
hex.string(v: 1234)// Returns 4d2
// Returns "true"
```
#### Convert a duration to a hexadecimal string value
### Convert a boolean to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: 1m)
hex.string(v: true)// Returns "true"
// Returns "1m"
```
#### Convert a time to a hexadecimal string value
### Convert a duration to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: 2021-01-01T00:00:00Z)
hex.string(v: 1m)// Returns "1m"
// Returns "2021-01-01T00:00:00Z"
```
#### Convert an integer to a hexadecimal string value
### Convert a time to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: 1234)
hex.string(v: 2021-01-01T00:00:00Z)// Returns "2021-01-01T00:00:00Z"
// Returns "4d2"
```
#### Convert a uinteger to a hexadecimal string value
### Convert an integer to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: uint(v: 5678))
hex.string(v: 1234)// Returns "4d2"
// Returns "162e"
```
#### Convert a float to a hexadecimal string value
### Convert a uinteger to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: 10.12)
hex.string(v: uint(v: 5678))// Returns "162e"
// Returns "10.12"
```
#### Convert bytes to a hexadecimal string value
### Convert a float to a hexadecimal string value
```js
import "contrib/bonitoo-io/hex"
hex.string(v: bytes(v: "Hello world!"))
hex.string(v: 10.12)// Returns "10.12"
// Returns "48656c6c6f20776f726c6421"
```
#### Convert all values in a column to hexadecimal string values
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
2. Use `hex.string()` to update the value of a column.
### Convert bytes to a hexadecimal string value
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
```js
import "contrib/bonitoo-io/hex"
hex.string(v: bytes(v: "Hello world!"))// Returns "48656c6c6f20776f726c6421"
```
### Convert all values in a column to hexadecimal string values
Use `map()` to iterate over and update all input rows.
Use `hex.string()` to update the value of a column.
The following example uses data provided by the sampledata package.
```js
import "sampledata"
@ -123,49 +160,48 @@ data
```
{{< expand-wrapper >}}
{{% expand "View input and output" %}}
{{< flex >}}
{{% flex-content %}}
##### Input data
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
| :-- | :------------------- | -------------------------------------------: |
| t1 | 2021-01-01T00:00:00Z | -2000 |
| t1 | 2021-01-01T00:00:10Z | 10000 |
| t1 | 2021-01-01T00:00:20Z | 7000 |
| t1 | 2021-01-01T00:00:30Z | 17000 |
| t1 | 2021-01-01T00:00:40Z | 15000 |
| t1 | 2021-01-01T00:00:50Z | 4000 |
{{% expand "View example input and ouput" %}}
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
| :-- | :------------------- | -------------------------------------------: |
| t2 | 2021-01-01T00:00:00Z | 19000 |
| t2 | 2021-01-01T00:00:10Z | 4000 |
| t2 | 2021-01-01T00:00:20Z | -3000 |
| t2 | 2021-01-01T00:00:30Z | 19000 |
| t2 | 2021-01-01T00:00:40Z | 13000 |
| t2 | 2021-01-01T00:00:50Z | 1000 |
#### Input data
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | ----------------------------------------------: |
| 2021-01-01T00:00:00Z | t1 | -7d0 |
| 2021-01-01T00:00:10Z | t1 | 2710 |
| 2021-01-01T00:00:20Z | t1 | 1b58 |
| 2021-01-01T00:00:30Z | t1 | 4268 |
| 2021-01-01T00:00:40Z | t1 | 3a98 |
| 2021-01-01T00:00:50Z | t1 | fa0 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | -2000 | t1 |
| 2021-01-01T00:00:10Z | 10000 | t1 |
| 2021-01-01T00:00:20Z | 7000 | t1 |
| 2021-01-01T00:00:30Z | 17000 | t1 |
| 2021-01-01T00:00:40Z | 15000 | t1 |
| 2021-01-01T00:00:50Z | 4000 | t1 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 19000 | t2 |
| 2021-01-01T00:00:10Z | 4000 | t2 |
| 2021-01-01T00:00:20Z | -3000 | t2 |
| 2021-01-01T00:00:30Z | 19000 | t2 |
| 2021-01-01T00:00:40Z | 13000 | t2 |
| 2021-01-01T00:00:50Z | 1000 | t2 |
#### Output data
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | | t1 |
| 2021-01-01T00:00:10Z | | t1 |
| 2021-01-01T00:00:20Z | | t1 |
| 2021-01-01T00:00:30Z | | t1 |
| 2021-01-01T00:00:40Z | | t1 |
| 2021-01-01T00:00:50Z | | t1 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | | t2 |
| 2021-01-01T00:00:10Z | | t2 |
| 2021-01-01T00:00:20Z | | t2 |
| 2021-01-01T00:00:30Z | | t2 |
| 2021-01-01T00:00:40Z | | t2 |
| 2021-01-01T00:00:50Z | | t2 |
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | ----------------------------------------------: |
| 2021-01-01T00:00:00Z | t2 | 4a38 |
| 2021-01-01T00:00:10Z | t2 | fa0 |
| 2021-01-01T00:00:20Z | t2 | -bb8 |
| 2021-01-01T00:00:30Z | t2 | 4a38 |
| 2021-01-01T00:00:40Z | t2 | 32c8 |
| 2021-01-01T00:00:50Z | t2 | 3e8 |
{{% /flex-content %}}
{{< /flex >}}
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,112 +1,61 @@
---
title: hex.uint() function
description: >
`hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer.
`hex.uint()` converts a hexadecimal string to an unsigned integer.
menu:
flux_0_x_ref:
name: hex.uint
parent: hex
weight: 302
related:
- /flux/v0.x/data-types/basic/uint/
flux/v0.x/tags: [type-conversions]
parent: contrib/bonitoo-io/hex
identifier: contrib/bonitoo-io/hex/uint
weight: 301
---
`hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/hex/hex.flux#L149-L149
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`hex.uint()` converts a hexadecimal string to an unsigned integer.
##### Function type signature
```js
import "contrib/bonitoo-io/hex"
hex.uint(v: "4d2")
// Returns 1234
(v: string) => uint
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v {data-type="string"}
Value to convert.
### v
({{< req >}})
String to convert.
## Examples
- [Convert a hexadecimal string to an unsigned integer](#convert-a-hexadecimal-string-to-an-unsigned-integer)
- [Convert all hexadecimal string values in a column to unsigned integers](#convert-all-hexadecimal-string-values-in-a-column-to-unsigned-integers)
#### Convert a hexadecimal string to an unsigned integer
```js
import "contrib/bonitoo-io/hex"
hex.uint(v: "-d431")
// Returns -54321
```
#### Convert all hexadecimal string values in a column to unsigned integers
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
2. Use `hex.uint()` to update the value of a column.
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
### Convert a hexadecimal string to an unsigned integer
```js
import "contrib/bonitoo-io/hex"
import "sampledata"
data =
sampledata.uint()
|> map(fn: (r) => ({r with _value: hex.string(v: r._value)}))
hex.uint(v: "4d2")// Returns 1234
data
|> map(fn: (r) => ({r with _value: hex.uint(v: r._value)}))
```
{{< expand-wrapper >}}
{{% expand "View input and output" %}}
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | -------------------------------------------------: |
| 2021-01-01T00:00:00Z | t1 | fffffffffffffffe |
| 2021-01-01T00:00:10Z | t1 | a |
| 2021-01-01T00:00:20Z | t1 | 7 |
| 2021-01-01T00:00:30Z | t1 | 11 |
| 2021-01-01T00:00:40Z | t1 | f |
| 2021-01-01T00:00:50Z | t1 | 4 |
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
| :------------------- | :-- | -------------------------------------------------: |
| 2021-01-01T00:00:00Z | t2 | 13 |
| 2021-01-01T00:00:10Z | t2 | 4 |
| 2021-01-01T00:00:20Z | t2 | fffffffffffffffd |
| 2021-01-01T00:00:30Z | t2 | 13 |
| 2021-01-01T00:00:40Z | t2 | d |
| 2021-01-01T00:00:50Z | t2 | 1 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| tag | _time | _value _<span style="opacity:.5;">(uint)</span>_ |
| :-- | :------------------- | -----------------------------------------------: |
| t1 | 2021-01-01T00:00:00Z | 18446744073709551614 |
| t1 | 2021-01-01T00:00:10Z | 10 |
| t1 | 2021-01-01T00:00:20Z | 7 |
| t1 | 2021-01-01T00:00:30Z | 17 |
| t1 | 2021-01-01T00:00:40Z | 15 |
| t1 | 2021-01-01T00:00:50Z | 4 |
| tag | _time | _value _<span style="opacity:.5;">(uint)</span>_ |
| :-- | :------------------- | -----------------------------------------------: |
| t2 | 2021-01-01T00:00:00Z | 19 |
| t2 | 2021-01-01T00:00:10Z | 4 |
| t2 | 2021-01-01T00:00:20Z | 18446744073709551613 |
| t2 | 2021-01-01T00:00:30Z | 19 |
| t2 | 2021-01-01T00:00:40Z | 13 |
| t2 | 2021-01-01T00:00:50Z | 1 |
{{% /flex-content %}}
{{< /flex >}}
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,28 +1,44 @@
---
title: Flux servicenow package
list_title: servicenow package
title: servicenow package
description: >
The Flux `servicenow` package provides functions that send events to
[ServiceNow](https://servicenow.com).
The `servicenow` package provides functions for sending events to [ServiceNow](https://www.servicenow.com/).
menu:
flux_0_x_ref:
name: servicenow
parent: bonitoo-io
weight: 202
flux/v0.x/tags: [functions, servicenow, package]
name: servicenow
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/servicenow
weight: 31
cascade:
introduced: 0.136.0
---
The Flux `servicenow` package provides functions that send events to
[ServiceNow](https://servicenow.com).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/servicenow/servicenow.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `servicenow` package provides functions for sending events to [ServiceNow](https://www.servicenow.com/).
Import the `contrib/bonitoo-io/servicenow` package:
```js
import "contrib/bonitoo-io/servicenow"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,98 +1,84 @@
---
title: servicenow.endpoint() function
description: >
The `servicenow.endpoint()` function sends events to [ServiceNow](https://servicenow.com)
using data from input rows.
`servicenow.endpoint()` sends events to [ServiceNow](https://servicenow.com/) using data from input rows.
menu:
flux_0_x_ref:
name: servicenow.endpoint
parent: servicenow
weight: 202
flux/v0.x/tags: [notification endpoints]
parent: contrib/bonitoo-io/servicenow
identifier: contrib/bonitoo-io/servicenow/endpoint
weight: 301
---
The `servicenow.endpoint()` function sends events to [ServiceNow](https://servicenow.com)
using data from input rows.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/servicenow/servicenow.flux#L194-L223
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`servicenow.endpoint()` sends events to [ServiceNow](https://servicenow.com/) using data from input rows.
##### Function type signature
```js
import "contrib/bonitoo-io/servicenow"
servicenow.endpoint(
url: "https://example-tenant.service-now.com/api/global/em/jsonv2",
username: "example-username",
password: "example-password"
)
(
password: string,
url: string,
username: string,
?source: A,
) => (
mapFn: (
r: B,
) => {
C with
severity: J,
resource: I,
node: H,
metricType: G,
metricName: F,
messageKey: E,
description: D,
},
) => (<-tables: stream[B]) => stream[{B with _sent: string}] where J: Equatable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
ServiceNow web service URL.
### username {data-type=" string"}
### username
({{< req >}})
ServiceNow username to use for HTTP BASIC authentication.
### password {data-type="string"}
### password
({{< req >}})
ServiceNow password to use for HTTP BASIC authentication.
## Usage
`servicenow.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the ServiceNow API request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following properties:
### source
- `description`
- `severity`
- `source`
- `node`
- `metricType`
- `resource`
- `metricName`
- `messageKey`
- `additionalInfo`
Source name. Default is `"Flux"`.
_For more information, see [`servicenow.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/servicenow/event/#parameters)._
## Examples
##### Send critical events to ServiceNow
```js
import "contrib/bonitoo-io/servicenow"
import "influxdata/influxdb/secrets"
username = secrets.get(key: "SERVICENOW_USERNAME")
password = secrets.get(key: "SERVICENOW_PASSWORD")
endpoint =
servicenow.endpoint(
url: "https://example-tenant.service-now.com/api/global/em/jsonv2",
username: username,
password: password,
)
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) =>
({
node: r.host,
metricType: r._measurement,
resource: r.instance,
metricName: r._field,
severity: "critical",
additionalInfo: {"devId": r.dev_id},
}),
)()
```

View File

@ -1,62 +1,89 @@
---
title: servicenow.event() function
description: >
The `servicenow.event()` function sends an event to ServiceNow.
`servicenow.event()` sends an event to [ServiceNow](https://servicenow.com/).
menu:
flux_0_x_ref:
name: servicenow.event
parent: servicenow
weight: 202
parent: contrib/bonitoo-io/servicenow
identifier: contrib/bonitoo-io/servicenow/event
weight: 301
flux/v0.x/tags: [single notification]
---
The `servicenow.event()` function sends an event to [ServiceNow](https://servicenow.com).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/servicenow/servicenow.flux#L81-L127
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`servicenow.event()` sends an event to [ServiceNow](https://servicenow.com/).
ServiceNow Event API fields are described in
[ServiceNow Create Event documentation](https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMCreateEventManually.html).
##### Function type signature
```js
import "contrib/bonitoo-io/servicenow"
servicenow.event(
url: "https://example-tenant.service-now.com/api/global/em/jsonv2",
username: "example-username",
password: "example-password",
description: "Example event description.",
severity: "minor",
source: "",
node: "",
metricType: "",
resource: "",
metricName: "",
messageKey: "",
additionalInfo: {},
)
(
description: A,
password: string,
severity: B,
url: string,
username: string,
?additionalInfo: C,
?messageKey: D,
?metricName: E,
?metricType: F,
?node: G,
?resource: H,
?source: I,
) => int where B: Equatable, C: Equatable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
_ServiceNow Event API fields are described in [ServiceNow Create Event documentation](https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMCreateEventManually.html)._
### url {data-type="string"}
### url
({{< req >}})
ServiceNow web service URL.
### username {data-type=" string"}
### username
({{< req >}})
ServiceNow username to use for HTTP BASIC authentication.
### password {data-type="string"}
### password
({{< req >}})
ServiceNow password to use for HTTP BASIC authentication.
### description {data-type="string"}
### description
({{< req >}})
Event description.
### severity {data-type="string"}
### severity
({{< req >}})
Severity of the event.
**Supported values:**
Supported values:
- `critical`
- `major`
- `minor`
@ -64,37 +91,59 @@ Severity of the event.
- `info`
- `clear`
### source {data-type="string"}
Source name.
Default is `"Flux"`.
### source
Source name. Default is `"Flux"`.
### node
### node {data-type="string"}
Node name or IP address related to the event.
Default is an empty string (`""`).
### metricType {data-type="string"}
### metricType
Metric type related to the event (for example, `CPU`).
Default is an empty string (`""`).
### resource {data-type="string"}
### resource
Resource related to the event (for example, `CPU-1`).
Default is an empty string (`""`).
### metricName {data-type="string"}
### metricName
Metric name related to the event (for example, `usage_idle`).
Default is an empty string (`""`).
### messageKey {data-type="string"}
### messageKey
Unique identifier of the event (for example, the InfluxDB alert ID).
Default is an empty string (`""`).
If an empty string, ServiceNow generates a value.
### additionalInfo {data-type="record"}
### additionalInfo
Additional information to include with the event.
## Examples
##### Send the last reported value and incident type to ServiceNow
### Send the last reported value and incident type to ServiceNow
```js
import "contrib/bonitoo-io/servicenow"
import "influxdata/influxdb/secrets"
@ -127,3 +176,4 @@ servicenow.event(
additionalInfo: {"devId": r.dev_id},
)
```

View File

@ -1,34 +1,46 @@
---
title: Flux tickscript package
list_title: tickscript package
title: tickscript package
description: >
The Flux `tickscript` package provides functions to help migrate Kapacitor TICKscripts to Flux tasks.
Import the `contrib/bonitoo-io/tickscript` package.
The `tickscript` package provides functions to help migrate
Kapacitor [TICKscripts](https://docs.influxdata.com/kapacitor/latest/tick/) to Flux tasks.
menu:
flux_0_x_ref:
name: tickscript
parent: bonitoo-io
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/
flux/v0.x/tags: [functions, tickscript, package]
name: tickscript
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/tickscript
weight: 31
cascade:
introduced: 0.111.0
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@bonitoo-io](https://github.com/bonitoo-io), [@alespour](https://github.com/alespour)
**InfluxDB Slack:** [@Ales Pour](https://influxdata.com/slack)
---
The Flux `tickscript` package provides functions to help migrate Kapacitor TICKscripts to Flux tasks.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `tickscript` package provides functions to help migrate
Kapacitor [TICKscripts](https://docs.influxdata.com/kapacitor/latest/tick/) to Flux tasks.
Import the `contrib/bonitoo-io/tickscript` package:
```js
import "contrib/bonitoo-io/tickscript"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,97 +1,158 @@
---
title: tickscript.alert() function
description: >
The `tickscript.alert()` function identifies events of varying severity levels
and writes them to the `statuses` measurement in the InfluxDB
`_monitoring` system bucket.
`tickscript.alert()` identifies events of varying severity levels
and writes them to the `statuses` measurement in the InfluxDB `_monitoring`
system bucket.
menu:
flux_0_x_ref:
name: tickscript.alert
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/alert/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/alert/
related:
- /{{< latest "kapacitor" >}}/nodes/alert_node/, Kapacitor AlertNode
flux/v0.x/tags: [transformations]
introduced: 0.111.0
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/alert
weight: 301
flux/v0.x/tags: [transformations, outputs]
---
The `tickscript.alert()` function identifies events of varying severity levels
and writes them to the `statuses` measurement in the InfluxDB
[`_monitoring` system bucket](/{{< latest "influxdb" >}}/reference/internals/system-buckets/).
<!------------------------------------------------------------------------------
_This function is comparable to the [Kapacitor AlertNode](/{{< latest "kapacitor" >}}/nodes/alert_node/)._
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L103-L140
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.alert()` identifies events of varying severity levels
and writes them to the `statuses` measurement in the InfluxDB `_monitoring`
system bucket.
This function is comparable to
TICKscript [`alert()`](https://docs.influxdata.com/kapacitor/v1.6/nodes/alert_node/).
##### Function type signature
```js
import "contrib/bonitoo-io/tickscript"
tickscript.alert(
check: {id: "000000000000", name: "Example check name", type: "threshold", tags: {}},
id: (r) => "000000000000",
details: (r) => "",
message: (r) => "Threshold Check: ${r._check_name} is: ${r._level}",
crit: (r) => false,
warn: (r) => false,
info: (r) => false,
ok: (r) => true,
topic: "",
)
(
<-tables: stream[t12],
check: {A with tags: E, _type: D, _check_name: C, _check_id: B},
?crit: (r: {F with _time: H, _measurement: G}) => bool,
?details: (r: {I with id: J, _check_name: C, _check_id: B}) => t10,
?id: (r: {I with _check_name: C, _check_id: B}) => J,
?info: (r: {F with _time: H, _measurement: G}) => bool,
?message: (
r: {
F with
_type: D,
_time: H,
_time: time,
_source_timestamp: int,
_source_measurement: G,
_measurement: G,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
},
) => t11,
?ok: (r: {F with _time: H, _measurement: G}) => bool,
?topic: string,
?warn: (r: {F with _time: H, _measurement: G}) => bool,
) => stream[{
F with
_type: D,
_time: H,
_time: time,
_source_timestamp: int,
_source_measurement: G,
_message: t11,
_measurement: G,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
}] where E: Record, I: Record, t12: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### check {data-type="record"}
### check
({{< req >}})
InfluxDB check data.
_See [`tickscript.defineCheck()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck/)._
See `tickscript.defineCheck()`.
### id {data-type="function"}
Function that returns the InfluxDB check ID provided by the [`check` record](#check).
### id
Function that returns the InfluxDB check ID provided by the check record.
Default is `(r) => "${r._check_id}"`.
### details {data-type="function"}
### details
Function to return the InfluxDB check details using data from input rows.
Default is `(r) => ""`.
### message {data-type="function"}
### message
Function to return the InfluxDB check message using data from input rows.
Default is `(r) => "Threshold Check: ${r._check_name} is: ${r._level}"`.
### crit {data-type="function"}
Predicate function to determine `crit` status.
Default is `(r) => false`.
### warn {data-type="function"}
Predicate function to determine `warn` status.
Default is `(r) => false`.
### info {data-type="function"}
Predicate function to determine `info` status.
Default is `(r) => false`.
### crit
Predicate function to determine `crit` status. Default is `(r) => false`.
### warn
Predicate function to determine `warn` status. Default is `(r) => false`.
### info
Predicate function to determine `info` status. Default is `(r) => false`.
### ok
Predicate function to determine `ok` status. Default is `(r) => true`.
### topic
Check topic. Default is `""`.
### tables
Input data. Default is piped-forward data (`<-`).
### ok {data-type="function"}
Predicate function to determine `ok` status.
Default is `(r) => true`.
### topic {data-type="string"}
Check topic.
Default is `""`.
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
## Examples
##### Store alert statuses for error counts
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[Flux](#)
[TICKscript](#)
{{% /code-tabs %}}
{{% code-tab-content %}}
### Store alert statuses for error counts
```js
import "contrib/bonitoo-io/tickscript"
@ -111,20 +172,4 @@ from(bucket: "example-bucket")
info: (r) => r._value > 10,
)
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```javascript
data = batch
|query('SELECT count(value) from errors')
.every(1m)
data
|alert()
.id('kapacitor/{{ index .Tags "service" }}')
.message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}')
.info(lambda: "value" > 10)
.warn(lambda: "value" > 20)
.crit(lambda: "value" > 30)
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}

View File

@ -1,67 +1,69 @@
---
title: tickscript.compute() function
description: >
The `tickscript.compute()` function is an alias for `tickscript.select()` that
changes a column's name and optionally applies an aggregate or selector function
to values in the column.
`tickscript.compute()` is an alias for `tickscript.select()` that changes a columns name and
optionally applies an aggregate or selector function.
menu:
flux_0_x_ref:
name: tickscript.compute
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/compute/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/compute/
related:
- /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/
- /{{< latest "kapacitor" >}}/nodes/query_node/
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/compute
weight: 301
flux/v0.x/tags: [transformations]
---
The `tickscript.compute()` function is an **alias for
[`tickscript.select()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/)**
that changes a column's name and optionally applies an aggregate or selector function.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L387-L387
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.compute()` is an alias for `tickscript.select()` that changes a columns name and
optionally applies an aggregate or selector function.
##### Function type signature
```js
import "contrib/bonitoo-io/tickscript"
tickscript.compute(
column: "_value",
fn: sum,
as: "example-name",
)
(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record
```
#### TICKscript helper function
`tickscript.select()` is a helper function meant to replicate TICKscript operations
like the following:
```js
// Rename
query("SELECT x AS y")
// Aggregate and rename
query("SELECT f(x) AS y")
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column {data-type="string"}
Column to operate on.
Default is `_value`.
### fn {data-type="function"}
[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors)
function to apply.
### as {data-type="string"}
### as
({{< req >}})
New column name.
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
## Examples
For examples, see [`tickscript.select()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/#examples).
### column
Column to operate on. Default is `_value`.
### fn
Aggregate or selector function to apply.
### tables
Input data. Default is piped-forward data (`<-`).

View File

@ -1,85 +1,138 @@
---
title: tickscript.deadman() function
description: >
The `tickscript.deadman()` function detects low data throughput and writes a point
with a critical status to the InfluxDB `_monitoring` system bucket.
`tickscript.deadman()` detects low data throughput and writes a point with a critical status to
the InfluxDB `_monitoring` system bucket.
menu:
flux_0_x_ref:
name: tickscript.deadman
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/deadman/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/deadman/
related:
- /{{< latest "kapacitor" >}}/nodes/batch_node/#deadman, Kapacitor BatchNode  Deadman
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/deadman
weight: 301
flux/v0.x/tags: [transformations]
introduced: 0.111.0
---
The `tickscript.deadman()` function detects low data throughput and writes a point
with a critical status to the InfluxDB [`_monitoring` system bucket](/{{< latest "influxdb" >}}/reference/internals/system-buckets/).
For each input table containing a number of rows less than or equal to the specified
[threshold](#threshold), the function assigns a `crit` value to the `_level` column.
<!------------------------------------------------------------------------------
_This function is comparable to the [Kapacitor AlertNode deadman](/{{< latest "kapacitor" >}}/nodes/alert_node/#deadman)._
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L186-L242
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.deadman()` detects low data throughput and writes a point with a critical status to
the InfluxDB `_monitoring` system bucket.
For each input table containing a number of rows less than or equal to the specified threshold,
the function assigns a `crit` value to the` _level` column.
This function is comparable to [Kapacitor AlertNode deadman](https://docs.influxdata.com/kapacitor/latest/nodes/stream_node/#deadman).
##### Function type signature
```js
import "contrib/bonitoo-io/tickscript"
tickscript.deadman(
check: {},
measurement: "example-measurement",
threshold: 0,
id: (r) => "${r._check_id}",
message: (r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive"),
topic: "",
)
(
<-tables: stream[t12],
check: {A with tags: E, _type: D, _check_name: C, _check_id: B},
measurement: string,
?id: (r: {F with _check_name: C, _check_id: B}) => G,
?message: (
r: {
H with
dead: bool,
_type: D,
_time: J,
_time: time,
_source_timestamp: int,
_source_measurement: I,
_measurement: I,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
},
) => t10,
?threshold: t11,
?topic: string,
) => stream[{
H with
dead: bool,
_type: D,
_time: J,
_time: time,
_source_timestamp: int,
_source_measurement: I,
_message: t10,
_measurement: I,
_measurement: string,
_level: string,
_check_name: C,
_check_id: B,
}] where E: Record, F: Record, t11: Comparable + Equatable, t12: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### check {data-type="record"}
### check
({{< req >}})
InfluxDB check data.
_See [`tickscript.defineCheck()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/definecheck/)._
InfluxDB check data. See `tickscript.defineCheck()`.
### measurement {data-type="string"}
### measurement
({{< req >}})
Measurement name.
Should match the queried measurement.
Measurement name. Should match the queried measurement.
### threshold {data-type="int"}
Count threshold.
The function assigns a `crit` status to input tables with a number of rows less
than or equal to the threshold.
Default is `0`.
### id {data-type="function"}
Function that returns the InfluxDB check ID provided by the [`check` record](#check).
### threshold
Count threshold. Default is `0`.
The function assigns a `crit` status to input tables with a number of rows less than or equal to the threshold.
### id
Function that returns the InfluxDB check ID provided by the check record.
Default is `(r) => "${r._check_id}"`.
### message {data-type="function"}
### message
Function that returns the InfluxDB check message using data from input rows.
Default is `(r) => "Deadman Check: ${r._check_name} is: " + (if r.dead then "dead" else "alive")`.
### topic {data-type="string"}
Check topic.
Default is `""`.
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
### topic
Check topic. Default is `""`.
### tables
Input data. Default is piped-forward data (`<-`).
## Examples
{{< code-tabs-wrapper >}}
{{% code-tabs %}}
[Flux](#)
[TICKscript](#)
{{% /code-tabs %}}
{{% code-tab-content %}}
```javascript
### Detect when a series stops reporting
```js
import "contrib/bonitoo-io/tickscript"
option task = {name: "Example task", every: 1m}
@ -93,17 +146,4 @@ from(bucket: "example-bucket")
threshold: 2,
)
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```javascript
data = batch
|query('SELECT value from pulse')
.every(1m)
data
|deadman(2.0, 1m)
.id('kapacitor/{{ index .Tags "service" }}')
.message('{{ .ID }} is {{ .Level }} value:{{ index .Fields "value" }}')
```
{{% /code-tab-content %}}
{{< /code-tabs-wrapper >}}

View File

@ -1,66 +1,81 @@
---
title: tickscript.defineCheck() function
description: >
The `tickscript.defineCheck()` function creates and returns a record with custom
check data required by `tickscript.alert()` and `tickscript.deadman()`.
`tickscript.defineCheck()` creates custom check data required by `alert()` and `deadman()`.
menu:
flux_0_x_ref:
name: tickscript.defineCheck
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/definecheck/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/definecheck/
introduced: 0.111.0
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/defineCheck
weight: 301
---
The `tickscript.defineCheck()` function creates and returns a record with custom check data required by
[`tickscript.alert()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/alert/) and
[`tickscript.deadman()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/deadman/).
This check data specifies information about the check in the InfluxDB monitoring system.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L47-L49
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.defineCheck()` creates custom check data required by `alert()` and `deadman()`.
##### Function type signature
```js
(id: A, name: B, ?type: C) => {tags: {}, _type: C, _check_name: B, _check_id: A}
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### id
({{< req >}})
InfluxDB check ID.
### name
({{< req >}})
InfluxDB check name.
### type
InfluxDB check type. Default is `custom`.
**Valid values**:
- `threshold`
-`deadman`
-`custom`
## Examples
### Generate InfluxDB check data
```js
import "contrib/bonitoo-io/tickscript"
tickscript.defineCheck(
id: "000000000000",
name: "Example check name",
type: "custom",
)
tickscript.defineCheck(id: "000000000000", name: "Example check name")// Returns:
// {
// _check_id: 000000000000,
// _check_name: Example check name,
// _type: custom,
// tags: {}
// }
```
## Parameters
## id {data-type="string"}
({{< req >}})
InfluxDB check ID.
## name {data-type="string"}
({{< req >}})
InfluxDB check name.
## type {data-type="string"}
InfluxDB check type.
Default is `custom`.
**Supported values:**
- threshold
- deadman
- custom
## Examples
##### Generate InfluxDB check data
```javascript
import "contrib/bonitoo-io/tickscript"
tickscript.defineCheck(id: "000000000000", name: "Example check name")
// The function above returns: {
// _check_id: "000000000000",
// _check_name: "Example check name",
// _type: "custom",
// tags: {}
// }
```

View File

@ -1,53 +1,110 @@
---
title: tickscript.groupBy() function
description: >
The `tickscript.groupBy()` function groups results by the `_measurement` column
and other specified columns.
`tickscript.groupBy()` groups results by the `_measurement` column and other specified columns.
menu:
flux_0_x_ref:
name: tickscript.groupBy
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/groupby/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/groupby/
related:
- /{{< latest "kapacitor" >}}/nodes/query_node/#groupby, Kapacitor QueryNode - groupBy
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/groupBy
weight: 301
flux/v0.x/tags: [transformations]
---
The `tickscript.groupBy()` function groups results by the `_measurement` column and
other specified columns.
<!------------------------------------------------------------------------------
_This function is comparable to [Kapacitor QueryNode .groupBy](/{{< latest "kapacitor" >}}/nodes/query_node/#groupby)._
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
{{% note %}}
To group by intervals of time, use [`window()`](/flux/v0.x/stdlib/universe/window/)
or [`tickscript.selectWindow()`](/flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow/).
{{% /note %}}
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L425-L429
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.groupBy()` groups results by the `_measurement` column and other specified columns.
This function is comparable to [Kapacitor QueryNode .groupBy](https://docs.influxdata.com/kapacitor/latest/nodes/query_node/#groupby).
**Note**: To group by time intervals, use `window()` or `tickscript.selectWindow()`.
##### Function type signature
```js
import "contrib/bonitoo-io/tickscript"
tickscript.groupBy(columns: ["exampleColumn"])
(<-tables: stream[A], columns: [string]) => stream[A] where A: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### columns {data-type="array of strings"}
### columns
({{< req >}})
List of columns to group by.
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
### tables
Input data. Default is piped-forward data (`<-`).
## Examples
##### Group by host and region
### Group by host and region
```js
import "contrib/bonitoo-io/tickscript"
data
|> tickscript.groupBy(columns: ["host", "region"])
```
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
#### Input data
| _time | _measurement | host | region | _field | _value |
| -------------------- | ------------- | ----- | ------- | ------- | ------- |
| 2021-01-01T00:00:00Z | m | h1 | east | foo | 1.2 |
| 2021-01-01T00:01:00Z | m | h1 | east | foo | 3.4 |
| 2021-01-01T00:00:00Z | m | h2 | east | foo | 2.3 |
| 2021-01-01T00:01:00Z | m | h2 | east | foo | 5.6 |
| 2021-01-01T00:00:00Z | m | h3 | west | foo | 1.2 |
| 2021-01-01T00:01:00Z | m | h3 | west | foo | 3.4 |
| 2021-01-01T00:00:00Z | m | h4 | west | foo | 2.3 |
| 2021-01-01T00:01:00Z | m | h4 | west | foo | 5.6 |
#### Output data
| _time | *_measurement | *host | *region | _field | _value |
| -------------------- | ------------- | ----- | ------- | ------- | ------- |
| 2021-01-01T00:00:00Z | m | h1 | east | foo | 1.2 |
| 2021-01-01T00:01:00Z | m | h1 | east | foo | 3.4 |
| _time | *_measurement | *host | *region | _field | _value |
| -------------------- | ------------- | ----- | ------- | ------- | ------- |
| 2021-01-01T00:00:00Z | m | h2 | east | foo | 2.3 |
| 2021-01-01T00:01:00Z | m | h2 | east | foo | 5.6 |
| _time | *_measurement | *host | *region | _field | _value |
| -------------------- | ------------- | ----- | ------- | ------- | ------- |
| 2021-01-01T00:00:00Z | m | h3 | west | foo | 1.2 |
| 2021-01-01T00:01:00Z | m | h3 | west | foo | 3.4 |
| _time | *_measurement | *host | *region | _field | _value |
| -------------------- | ------------- | ----- | ------- | ------- | ------- |
| 2021-01-01T00:00:00Z | m | h4 | west | foo | 2.3 |
| 2021-01-01T00:01:00Z | m | h4 | west | foo | 5.6 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,112 +1,120 @@
---
title: tickscript.join() function
description: >
The `tickscript.join()` function merges two input streams into a single output
stream based on specified columns with equal values and appends a new measurement name.
`tickscript.join()` merges two input streams into a single output stream
based on specified columns with equal values and appends a new measurement name.
menu:
flux_0_x_ref:
name: tickscript.join
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/join/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/join/
related:
- /{{< latest "kapacitor" >}}/nodes/join_node/, Kapacitor JoinNode
- /flux/v0.x/stdlib/universe/join/
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/join
weight: 301
flux/v0.x/tags: [transformations]
---
The `tickscript.join()` function merges two input streams into a single output
stream based on specified columns with equal values and appends a new measurement name.
<!------------------------------------------------------------------------------
_This function is comparable to the [Kapacitor JoinNode](/{{< latest "kapacitor" >}}/nodes/join_node/)._
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L482-L486
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.join()` merges two input streams into a single output stream
based on specified columns with equal values and appends a new measurement name.
This function is comparable to [Kapacitor JoinNode](https://docs.influxdata.com/kapacitor/latest/nodes/join_node/).
##### Function type signature
```js
import "contrib/bonitoo-io/tickscript"
tickscript.join(
tables: {t1: example1, t2: example2},
on: ["_time"],
measurement: "example-measurement",
)
(measurement: A, tables: B, ?on: [string]) => stream[{C with _measurement: A}] where B: Record, C: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### tables {data-type="record"}
### tables
({{< req >}})
Map of two streams to join.
### on {data-type="array of strings"}
List of columns to join on.
Default is `["_time"]`.
### measurement {data-type="string"}
### on
List of columns to join on. Default is `["_time"]`.
### measurement
({{< req >}})
Measurement name to use in results.
## Examples
### Join two streams of data
#### Input data
{{< flex >}}
{{% flex-content %}}
##### metrics
| _time | host | _value |
|:----- |:---- | ------:|
| 2021-01-01T00:00:00Z | host1 | 1.2 |
| 2021-01-01T01:00:00Z | host1 | 0.8 |
| 2021-01-01T02:00:00Z | host1 | 3.2 |
| _time | host | _value |
|:----- |:---- | ------:|
| 2021-01-01T00:00:00Z | host2 | 8.4 |
| 2021-01-01T01:00:00Z | host2 | 7.3 |
| 2021-01-01T02:00:00Z | host2 | 7.9 |
{{% /flex-content %}}
{{% flex-content %}}
##### states
| _time | host | _value |
|:----- |:---- | ------:|
| 2021-01-01T00:00:00Z | host1 | dead |
| 2021-01-01T01:00:00Z | host1 | dead |
| 2021-01-01T02:00:00Z | host1 | alive |
| _time | host | _value |
|:----- |:---- | ------:|
| 2021-01-01T00:00:00Z | host2 | alive |
| 2021-01-01T01:00:00Z | host2 | alive |
| 2021-01-01T02:00:00Z | host2 | alive |
{{% /flex-content %}}
{{< /flex >}}
#### Query
```js
import "array"
import "contrib/bonitoo-io/tickscript"
metrics = //...
states = //...
metrics =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, host: "host1", _value: 1.2},
{_time: 2021-01-01T01:00:00Z, host: "host1", _value: 0.8},
{_time: 2021-01-01T02:00:00Z, host: "host1", _value: 3.2},
{_time: 2021-01-01T00:00:00Z, host: "host2", _value: 8.4},
{_time: 2021-01-01T01:00:00Z, host: "host2", _value: 7.3},
{_time: 2021-01-01T02:00:00Z, host: "host2", _value: 7.9},
],
)
|> group(columns: ["host"])
tickscript.join(
tables: {metric: metrics, state: states},
on: ["_time", "host"],
measurement: "example-m",
)
states =
array.from(
rows: [
{_time: 2021-01-01T00:00:00Z, host: "host1", _value: "dead"},
{_time: 2021-01-01T01:00:00Z, host: "host1", _value: "dead"},
{_time: 2021-01-01T02:00:00Z, host: "host1", _value: "alive"},
{_time: 2021-01-01T00:00:00Z, host: "host2", _value: "alive"},
{_time: 2021-01-01T01:00:00Z, host: "host2", _value: "alive"},
{_time: 2021-01-01T02:00:00Z, host: "host2", _value: "alive"},
],
)
|> group(columns: ["host"])
tickscript.join(tables: {metric: metrics, state: states}, on: ["_time", "host"], measurement: "example-m")
```
{{< expand-wrapper >}}
{{% expand "View example output" %}}
#### Output data
| _measurement | host | _time | _value_metric | _value_state |
|:------------ |:---- |:----- | -------------:| ------------:|
| example-m | host1 | 2021-01-01T00:00:00Z | 1.2 | dead |
| example-m | host1 | 2021-01-01T01:00:00Z | 0.8 | dead |
| example-m | host1 | 2021-01-01T02:00:00Z | 3.2 | alive |
| *_measurement | _time | _value_metric | _value_state | *host |
| ------------- | -------------------- | -------------- | ------------- | ----- |
| example-m | 2021-01-01T00:00:00Z | 1.2 | dead | host1 |
| example-m | 2021-01-01T01:00:00Z | 0.8 | dead | host1 |
| example-m | 2021-01-01T02:00:00Z | 3.2 | alive | host1 |
| _measurement | host | _time | _value_metric | _value_state |
|:------------ |:---- |:----- | -------------:| ------------:|
| example-m | host2 | 2021-01-01T00:00:00Z | 8.4 | alive |
| example-m | host2 | 2021-01-01T01:00:00Z | 7.3 | alive |
| example-m | host2 | 2021-01-01T02:00:00Z | 7.9 | alive |
| *_measurement | _time | _value_metric | _value_state | *host |
| ------------- | -------------------- | -------------- | ------------- | ----- |
| example-m | 2021-01-01T00:00:00Z | 8.4 | alive | host2 |
| example-m | 2021-01-01T01:00:00Z | 7.3 | alive | host2 |
| example-m | 2021-01-01T02:00:00Z | 7.9 | alive | host2 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,41 +1,41 @@
---
title: tickscript.select() function
description: >
The `tickscript.select()` function changes a column's name and optionally applies
an aggregate or selector function to values in the column.
`tickscript.select()` changes a columns name and optionally applies an aggregate or selector
function to values in the column.
menu:
flux_0_x_ref:
name: tickscript.select
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/select/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/select/
related:
- /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/selectwindow/
- /{{< latest "kapacitor" >}}/nodes/query_node/
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/select
weight: 301
flux/v0.x/tags: [transformations]
introduced: 0.111.0
---
The `tickscript.select()` function changes a column's name and optionally applies
an aggregate or selector function to values in the column.
<!------------------------------------------------------------------------------
```js
import "contrib/bonitoo-io/tickscript"
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L304-L312
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.select()` changes a columns name and optionally applies an aggregate or selector
function to values in the column.
## TICKscript helper function
`tickscript.select()` is a helper function meant to replicate TICKscript operations like the following:
tickscript.select(
column: "_value",
fn: sum,
as: "example-name",
)
```
#### TICKscript helper function
`tickscript.select()` is a helper function meant to replicate TICKscript operations
like the following:
```js
// Rename
query("SELECT x AS y")
@ -43,23 +43,40 @@ query("SELECT x AS y")
query("SELECT f(x) AS y")
```
##### Function type signature
```js
(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column {data-type="string"}
Column to operate on.
Default is `_value`.
### column
### fn {data-type="function"}
[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors)
function to apply.
Column to operate on. Default is `_value`.
### as {data-type="string"}
### fn
Aggregate or selector function to apply.
### as
({{< req >}})
New column name.
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
### tables
Input data. Default is piped-forward data (`<-`).
## Examples
@ -67,87 +84,153 @@ Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressi
- [Change the name of the value column and apply an aggregate function](#change-the-name-of-the-value-column-and-apply-an-aggregate-function)
- [Change the name of the value column and apply a selector function](#change-the-name-of-the-value-column-and-apply-a-selector-function)
---
### Change the name of the value column
#### Change the name of the value column
```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"
data
sampledata.int()
|> tickscript.select(as: "example-name")
```
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | _value |
|:----- | ------:|
| 2021-01-01T00:00:00Z | 1.2 |
| 2021-01-01T01:00:00Z | 3.2 |
| 2021-01-01T02:00:00Z | 4.0 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| _time | example-name |
|:----- | ------------:|
| 2021-01-01T00:00:00Z | 1.2 |
| 2021-01-01T01:00:00Z | 3.2 |
| 2021-01-01T02:00:00Z | 4.0 |
{{% /flex-content %}}
{{< /flex >}}
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
---
#### Input data
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |
#### Output data
| _time | example-name | *tag |
| -------------------- | ------------- | ---- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |
| _time | example-name | *tag |
| -------------------- | ------------- | ---- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |
{{% /expand %}}
{{< /expand-wrapper >}}
### Change the name of the value column and apply an aggregate function
#### Change the name of the value column and apply an aggregate function
```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"
data
sampledata.int()
|> tickscript.select(as: "sum", fn: sum)
```
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | _value |
|:----- | ------:|
| 2021-01-01T00:00:00Z | 1.2 |
| 2021-01-01T01:00:00Z | 3.2 |
| 2021-01-01T02:00:00Z | 4.0 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| sum |
|:---:|
| 8.4 |
{{% /flex-content %}}
{{< /flex >}}
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
---
#### Input data
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |
#### Output data
| *tag | sum |
| ---- | ---- |
| t1 | 51 |
| *tag | sum |
| ---- | ---- |
| t2 | 53 |
{{% /expand %}}
{{< /expand-wrapper >}}
### Change the name of the value column and apply a selector function
#### Change the name of the value column and apply a selector function
```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"
data
sampledata.int()
|> tickscript.select(as: "max", fn: max)
```
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | _value |
|:----- | ------:|
| 2021-01-01T00:00:00Z | 1.2 |
| 2021-01-01T01:00:00Z | 3.2 |
| 2021-01-01T02:00:00Z | 4.0 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| _time | max |
|:----- | ---:|
| 2021-01-01T02:00:00Z | 4.0 |
{{% /flex-content %}}
{{< /flex >}}
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
---
#### Input data
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |
| _time | _value | *tag |
| -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |
#### Output data
| _time | max | *tag |
| -------------------- | ---- | ---- |
| 2021-01-01T00:00:30Z | 17 | t1 |
| _time | max | *tag |
| -------------------- | ---- | ---- |
| 2021-01-01T00:00:00Z | 19 | t2 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,112 +1,144 @@
---
title: tickscript.selectWindow() function
description: >
The `tickscript.selectWindow()` function changes a column's name, windows rows by time,
and applies an aggregate or selector function the specified column for each window of time.
`tickscript.selectWindow()` changes a columns name, windows rows by time, and then applies an
aggregate or selector function the specified column for each window of time.
menu:
flux_0_x_ref:
name: tickscript.selectWindow
parent: tickscript
weight: 302
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/tickscript/selectwindow/
- /influxdb/cloud/reference/flux/stdlib/contrib/tickscript/selectwindow/
related:
- /flux/v0.x/stdlib/contrib/bonitoo-io/tickscript/select/
- /{{< latest "kapacitor" >}}/nodes/query_node/
parent: contrib/bonitoo-io/tickscript
identifier: contrib/bonitoo-io/tickscript/selectWindow
weight: 301
flux/v0.x/tags: [transformations]
introduced: 0.111.0
---
The `tickscript.selectWindow()` function changes a column's name, windows rows by time,
and applies an aggregate or selector function the specified column for each window of time.
<!------------------------------------------------------------------------------
```js
import "contrib/bonitoo-io/tickscript"
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/tickscript/tickscript.flux#L356-L373
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`tickscript.selectWindow()` changes a columns name, windows rows by time, and then applies an
aggregate or selector function the specified column for each window of time.
## TICKscript helper function
`tickscript.selectWindow` is a helper function meant to replicate TICKscript operations like the following:
tickscript.selectWindow(
column: "_value",
fn: sum,
as: "example-name",
every: 1m,
defaultValue: 0.0,
)
```
#### TICKscript helper function
`tickscript.selectWindow()` is a helper function meant to replicate TICKscript operations
like the following:
```js
// Rename, window, and aggregate
query("SELECT f(x) AS y")
.groupBy(time(t), ...)
```
##### Function type signature
```js
(
<-tables: stream[D],
as: string,
defaultValue: A,
every: duration,
fn: (<-: stream[B], column: string) => stream[C],
?column: string,
) => stream[E] where B: Record, C: Record, D: Record, E: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column {data-type="string"}
Column to operate on.
Default is `_value`.
### column
_**Data type:** String_
Column to operate on. Default is _value.
### fn {data-type="function"}
### fn
({{< req >}})
[Aggregate](/flux/v0.x/function-types/#aggregates) or [selector](/flux/v0.x/function-types/#selectors)
function to apply.
Aggregate or selector function to apply.
### as {data-type="string"}
### as
({{< req >}})
New column name.
### every {data-type="duration"}
### every
({{< req >}})
Duration of windows.
### defaultValue {data-type="string, bool, int, uint, float, bytes"}
### defaultValue
({{< req >}})
Default fill value for null values in [`column`](#column).
Default fill value for null values in column.
Must be the same data type as column.
### tables
Input data. Default is piped-forward data (`<-`).
_Must be the same data type as `column`._
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
## Examples
#### Change the name of, window, and then aggregate the value column
### Change the name of, window, and then aggregate the value column
```js
import "contrib/bonitoo-io/tickscript"
data
|> tickscript.selectWindow(
fn: sum,
as: "example-name",
every: 1h,
defaultValue: 0.0,
)
|> tickscript.selectWindow(fn: sum, as: "example-name", every: 1h, defaultValue: 0)
```
{{< flex >}}
{{% flex-content %}}
##### Input data
| _time | _value |
|:----- | ------:|
| 2021-01-01T00:00:00Z | 1.2 |
| 2021-01-01T00:30:00Z | 0.8 |
| 2021-01-01T01:00:00Z | 3.2 |
| 2021-01-01T01:30:00Z | 3.9 |
| 2021-01-01T02:00:00Z | |
| 2021-01-01T02:30:00Z | 3.3 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output data
| _time | example-name |
|:----- | ------------:|
| 2021-01-01T00:59:59 | 2.0 |
| 2021-01-01T01:59:59 | 7.1 |
| 2021-01-01T02:59:59 | 3.3 |
{{% /flex-content %}}
{{< /flex >}}
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
#### Input data
| *_start | *_stop | _time | _value | *tag |
| -------------------- | -------------------- | -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 |
| *_start | *_stop | _time | _value | *tag |
| -------------------- | -------------------- | -------------------- | ------- | ---- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 |
#### Output data
| *_start | *_stop | *tag | example-name | _time |
| -------------------- | -------------------- | ---- | ------------- | -------------------- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 51 | 2021-01-01T00:01:00Z |
| *_start | *_stop | *tag | example-name | _time |
| -------------------- | -------------------- | ---- | ------------- | -------------------- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 53 | 2021-01-01T00:01:00Z |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,36 +1,44 @@
---
title: Flux victorops package
list_title: victorops package
title: victorops package
description: >
The Flux `victorops` package provides functions that send events to
[VictorOps](https://victorops.com).
The `victorops` package provides functions that send events to [VictorOps](https://victorops.com/).
menu:
flux_0_x_ref:
name: victorops
parent: bonitoo-io
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/
- /influxdb/cloud/reference/flux/stdlib/contrib/victorops/
flux/v0.x/tags: [functions, victorops, package]
introduced: 0.108.0
name: victorops
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/victorops
weight: 31
cascade:
introduced: 0.108.0
---
The Flux `victorops` package provides functions that send events to
[VictorOps](https://victorops.com).
<!------------------------------------------------------------------------------
{{% note %}}
#### VictorOps is now Splunk On-Call
Splunk acquired VictorOps and VictorOps is now
[Splunk On-Call](https://www.splunk.com/en_us/investor-relations/acquisitions/splunk-on-call.html).
{{% /note %}}
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/victorops/victorops.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `victorops` package provides functions that send events to [VictorOps](https://victorops.com/).
Import the `contrib/bonitoo-io/victorops` package:
```js
import "contrib/bonitoo-io/victorops"
```
**Note**: VictorOps is now Splunk On-Call
## Set up VictorOps
To send events to VictorOps with Flux:
@ -38,6 +46,7 @@ To send events to VictorOps with Flux:
2. [Create a REST integration routing key](https://help.victorops.com/knowledge-base/routing-keys/).
3. [Create a VictorOps API key](https://help.victorops.com/knowledge-base/api/).
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,88 +1,105 @@
---
title: victorops.alert() function
description: >
The `victorops.alert()` function sends an alert to VictorOps.
`victorops.alert()` sends an alert to VictorOps.
menu:
flux_0_x_ref:
name: victorops.alert
parent: victorops
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/event/
- /influxdb/cloud/reference/flux/stdlib/contrib/victorops/event/
- /flux/v0.x/stdlib/contrib/bonitoo-io/victorops/event/
introduced: 0.108.0
parent: contrib/bonitoo-io/victorops
identifier: contrib/bonitoo-io/victorops/alert
weight: 301
flux/v0.x/tags: [single notification]
---
The `victorops.alert()` function sends an alert to [VictorOps](https://www.victorops.com/).
<!------------------------------------------------------------------------------
{{% note %}}
#### VictorOps is now Splunk On-Call
Splunk acquired VictorOps and VictorOps is now
[Splunk On-Call](https://www.splunk.com/en_us/investor-relations/acquisitions/splunk-on-call.html).
{{% /note %}}
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/victorops/victorops.flux#L75-L98
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`victorops.alert()` sends an alert to VictorOps.
##### Function type signature
```js
import "contrib/bonitoo-io/victorops"
victorops.alert(
url: "https://alert.victorops.com/integrations/generic/00000000/alert/${api_key}/${routing_key}",
monitoringTool: "",
messageType: "CRITICAL",
entityID: "",
entityDisplayName: "",
stateMessage: "",
timestamp: now(),
)
(
messageType: A,
url: string,
?entityDisplayName: B,
?entityID: C,
?monitoringTool: D,
?stateMessage: E,
?timestamp: F,
) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
[VictorOps REST endpoint integration URL](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/).
VictorOps REST endpoint integration URL.
##### VictorOps URL example
```
https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key>
```
Example: `https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key>`
Replace `<api_key>` and `<routing_key>` with valid VictorOps API and routing keys.
_Replace `<api_key>` and `<routing_key>` with valid VictorOps API and routing keys._
### monitoringTool
### monitoringTool {data-type="string"}
Monitoring agent name.
Default is `""`.
Monitoring agent name. Default is `""`.
### messageType {data-type="string"}
### messageType
({{< req >}})
VictorOps [message type](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields)
(alert behavior).
**Valid values:**
VictorOps message type (alert behavior).
**Valid values**:
- `CRITICAL`
- `WARNING`
- `INFO`
### entityID {data-type="string"}
[Incident ID](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields).
Default is `""`.
### entityID
Incident ID. Default is `""`.
### entityDisplayName
Incident display name or summary. Default is `""`.
### stateMessage
Verbose incident message. Default is `""`.
### timestamp
Incident start time. Default is `now()`.
### entityDisplayName {data-type="string"}
[Incident display name or summary](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields).
Default is `""`.
### stateMessage {data-type="string"}
[Verbose incident message](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields).
Default is `""`.
### timestamp {data-type="time"}
[Incident start time](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/#recommended-rest-endpoint-integration-fields).
Default is `now()`.
## Examples
##### Send the last reported value and incident type to VictorOps
### Send the last reported value and incident type to VictorOps
```js
import "contrib/bonitoo-io/victorops"
import "influxdata/influxdb/secrets"
@ -111,3 +128,4 @@ victorops.alert(
stateMessage: "Last reported cpu_idle was ${string(v: r._value)}.",
)
```

View File

@ -1,95 +1,70 @@
---
title: victorops.endpoint() function
description: >
The `victorops.endpoint()` function sends events to VictorOps using data from input rows.
`victorops.endpoint()` sends events to VictorOps using data from input rows.
menu:
flux_0_x_ref:
name: victorops.endpoint
parent: victorops
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/victorops/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/victorops/endpoint/
flux/v0.x/tags: [notification endpoints]
introduced: 0.108.0
parent: contrib/bonitoo-io/victorops
identifier: contrib/bonitoo-io/victorops/endpoint
weight: 301
---
The `victorops.endpoint()` function sends events to VictorOps using data from input rows.
<!------------------------------------------------------------------------------
{{% note %}}
#### VictorOps is now Splunk On-Call
Splunk acquired VictorOps and VictorOps is now
[Splunk On-Call](https://www.splunk.com/en_us/investor-relations/acquisitions/splunk-on-call.html).
{{% /note %}}
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/victorops/victorops.flux#L161-L184
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`victorops.endpoint()` sends events to VictorOps using data from input rows.
##### Function type signature
```js
import "contrib/bonitoo-io/victorops"
victorops.endpoint(
url: "https://alert.victorops.com/integrations/generic/00000000/alert${apiKey}/${routingKey}",
)
(
url: string,
?monitoringTool: A,
) => (
mapFn: (
r: B,
) => {
C with
timestamp: H,
stateMessage: G,
messageType: F,
entityID: E,
entityDisplayName: D,
},
) => (<-tables: stream[B]) => stream[{B with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
[VictorOps REST endpoint integration URL](https://help.victorops.com/knowledge-base/rest-endpoint-integration-guide/).
VictorOps REST endpoint integration URL.
##### VictorOps URL example
```
https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key>
```
Example: `https://alert.victorops.com/integrations/generic/00000000/alert/<api_key>/<routing_key>`
Replace `<api_key>` and `<routing_key>` with valid VictorOps API and routing keys.
_Replace `<api_key>` and `<routing_key>` with valid VictorOps API and routing keys._
### monitoringTool
## Usage
`victorops.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
Tool to use for monitoring.
Default is `InfluxDB`.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `monitoringTool`
- `messageType`
- `entityID`
- `entityDisplayName`
- `stateMessage`
- `timestamp`
_For more information, see [`victorops.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/victorops/event/#parameters)._
## Examples
##### Send critical events to VictorOps
```js
import "contrib/bonitoo-io/victorops"
import "influxdata/influxdb/secrets"
apiKey = secrets.get(key: "VICTOROPS_API_KEY")
routingKey = secrets.get(key: "VICTOROPS_ROUTING_KEY")
url = "https://alert.victorops.com/integrations/generic/00000000/alert/${apiKey}/${routingKey}"
endpoint = victorops.endpoint(url: url)
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) =>
({
monitoringTool: "InfluxDB",
messageType: "CRITICAL",
entityID: "${r.host}-${r._field}-critical",
entityDisplayName: "Critical alert for ${r.host}",
stateMessage: "${r.host} is in a critical state. ${r._field} is ${string(v: r._value)}.",
timestamp: now(),
}),
)()
```

View File

@ -1,26 +1,44 @@
---
title: Flux zenoss package
list_title: zenoss package
title: zenoss package
description: >
The Flux `zenoss` package provides functions that send events to
[Zenoss](https://www.zenoss.com/).
The `zenoss` package provides functions that send events to [Zenoss](https://www.zenoss.com/).
menu:
flux_0_x_ref:
name: zenoss
parent: bonitoo-io
weight: 202
flux/v0.x/tags: [functions, zenoss, package]
introduced: 0.108.0
name: zenoss
parent: contrib/bonitoo-io
identifier: contrib/bonitoo-io/zenoss
weight: 31
cascade:
introduced: 0.108.0
---
The Flux `zenoss` package provides functions that send events to
[Zenoss](https://www.zenoss.com/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/zenoss/zenoss.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `zenoss` package provides functions that send events to [Zenoss](https://www.zenoss.com/).
Import the `contrib/bonitoo-io/zenoss` package:
```js
import "contrib/bonitoo-io/zenoss"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,118 +1,111 @@
---
title: zenoss.endpoint() function
description: >
The `zenoss.endpoint()` function sends events to Zenoss using data from input rows.
`zenoss.endpoint()` sends events to Zenoss using data from input rows.
menu:
flux_0_x_ref:
name: zenoss.endpoint
parent: zenoss
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/endpoint/
flux/v0.x/tags: [notification endpoints]
introduced: 0.108.0
parent: contrib/bonitoo-io/zenoss
identifier: contrib/bonitoo-io/zenoss/endpoint
weight: 301
---
The `zenoss.endpoint()` function sends events to Zenoss using data from input rows.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/zenoss/zenoss.flux#L202-L241
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`zenoss.endpoint()` sends events to Zenoss using data from input rows.
##### Function type signature
```js
import "contrib/bonitoo-io/zenoss"
zenoss.endpoint(
url: "https://example.zenoss.io:8080/zport/dmd/evconsole_router",
username: "example-user",
password: "example-password",
action: "EventsRouter",
method: "add_event",
type: "rpc",
tid: 1,
)
(
password: string,
url: string,
username: string,
?action: A,
?method: B,
?tid: C,
?type: D,
) => (
mapFn: (
r: E,
) => {
F with
summary: t13,
severity: t12,
message: t11,
eventClassKey: t10,
eventClass: J,
device: I,
component: H,
collector: G,
},
) => (<-tables: stream[E]) => stream[{E with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Zenoss [router endpoint URL](https://help.zenoss.com/zsd/RM/configuring-resource-manager/enabling-access-to-browser-interfaces/creating-and-changing-public-endpoints).
### username {data-type="string"}
### username
({{< req >}})
Zenoss username to use for HTTP BASIC authentication.
Default is `""` (no authentication).
### password {data-type="string"}
### password
({{< req >}})
Zenoss password to use for HTTP BASIC authentication.
Default is `""` (no authentication).
### action {data-type="string"}
Zenoss [router name](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/anatomy-of-an-api-request#AnatomyofanAPIrequest-RouterURL).
### action
Zenoss router name.
Default is `"EventsRouter"`.
### method {data-type="string"}
[EventsRouter method](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/codebase/routers/router-reference/eventsrouter).
### method
EventsRouter method.
Default is `"add_event"`.
### type {data-type="string"}
Event type.
Default is `"rpc"`.
### tid {data-type="int"}
### type
Event type. Default is `"rpc"`.
### tid
Temporary request transaction ID.
Default is `1`.
## Usage
`zenoss.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `summary`
- `device`
- `component`
- `severity`
- `eventClass`
- `eventClassKey`
- `collector`
- `message`
_For more information, see [`zenoss.event()` parameters](/flux/v0.x/stdlib/contrib/bonitoo-io/zenoss/event/#parameters)._
## Examples
##### Send critical events to Zenoss
```js
import "contrib/bonitoo-io/zenoss"
import "influxdata/influxdb/secrets"
url = "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router"
username = secrets.get(key: "ZENOSS_USERNAME")
password = secrets.get(key: "ZENOSS_PASSWORD")
endpoint = zenoss.endpoint(url: url, username: username, password: password)
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) =>
({
summary: "Critical event for ${r.host}",
device: r.deviceID,
component: r.host,
severity: "Critical",
eventClass: "/App",
eventClassKey: "",
collector: "",
message: "${r.host} is in a critical state.",
}),
)()
```

View File

@ -1,116 +1,174 @@
---
title: zenoss.event() function
description: >
The `zenoss.event()` function sends an event to Zenoss.
`zenoss.event()` sends an event to [Zenoss](https://www.zenoss.com/).
menu:
flux_0_x_ref:
name: zenoss.event
parent: zenoss
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/zenoss/event/
- /influxdb/cloud/reference/flux/stdlib/contrib/zenoss/event/
introduced: 0.108.0
parent: contrib/bonitoo-io/zenoss
identifier: contrib/bonitoo-io/zenoss/event
weight: 301
flux/v0.x/tags: [single notification]
---
The `zenoss.event()` function sends an event to [Zenoss](https://www.zenoss.com/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/bonitoo-io/zenoss/zenoss.flux#L86-L125
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`zenoss.event()` sends an event to [Zenoss](https://www.zenoss.com/).
##### Function type signature
```js
import "contrib/bonitoo-io/zenoss"
zenoss.event(
url: "https://example.zenoss.io:8080/zport/dmd/evconsole_router",
username: "example-user",
password: "example-password",
action: "EventsRouter",
method: "add_event",
type: "rpc",
tid: 1,
summary: "",
device: "",
component: "",
severity: "Critical",
eventClass: "",
eventClassKey: "",
collector: "",
message: "",
)
(
password: string,
severity: A,
url: string,
username: string,
?action: B,
?collector: C,
?component: D,
?device: E,
?eventClass: F,
?eventClassKey: G,
?message: H,
?method: I,
?summary: J,
?tid: t10,
?type: t11,
) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Zenoss [router endpoint URL](https://help.zenoss.com/zsd/RM/configuring-resource-manager/enabling-access-to-browser-interfaces/creating-and-changing-public-endpoints).
### username {data-type="string"}
### username
({{< req >}})
Zenoss username to use for HTTP BASIC authentication.
Default is `""` (no authentication).
### password {data-type="string"}
### password
({{< req >}})
Zenoss password to use for HTTP BASIC authentication.
Default is `""` (no authentication).
### action {data-type="string"}
Zenoss [router name](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/anatomy-of-an-api-request#AnatomyofanAPIrequest-RouterURL).
Default is `"EventsRouter"`.
### method {data-type="string"}
### action
Zenoss router name.
Default is "EventsRouter".
### method
[EventsRouter method](https://help.zenoss.com/dev/collection-zone-and-resource-manager-apis/codebase/routers/router-reference/eventsrouter).
Default is `"add_event"`.
Default is "add_event".
### type
### type {data-type="string"}
Event type.
Default is `"rpc"`.
Default is "rpc".
### tid
### tid {data-type="int"}
Temporary request transaction ID.
Default is `1`.
### summary {data-type="string"}
### summary
Event summary.
Default is `""`.
### device {data-type="string"}
### device
Related device.
Default is `""`.
### component {data-type="string"}
### component
Related component.
Default is `""`.
### severity {data-type="string"}
### severity
({{< req >}})
[Event severity level](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-severity-levels).
**Supported values:**
**Supported values**:
- Critical
- Warning
- Info
- Clear
### eventClass {data-type="string"}
### eventClass
[Event class](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/understanding-event-classes).
Default is `""`.
### eventClassKey {data-type="string"}
### eventClassKey
Event [class key](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-fields).
Default is `""`.
### collector {data-type="string"}
### collector
Zenoss [collector](https://help.zenoss.com/zsd/RM/administering-resource-manager/event-management/event-fields).
Default is `""`.
### message {data-type="string"}
### message
Related message.
Default is `""`.
## Examples
##### Send the last reported value and severity to Zenoss
### Send the last reported value and severity to Zenoss
```js
import "contrib/bonitoo-io/zenoss"
import "influxdata/influxdb/secrets"
@ -143,3 +201,4 @@ zenoss.event(
"Clear",
)
```

View File

@ -1,25 +1,36 @@
---
title: Packages contributed by chobbs
list_title: chobbs package
title: chobbs package
description: >
The `chobbs` package contains functions and packages contributed by [@chobbs](https://github.com/chobbs).
The `chobbs` package contains packages and functions contributed by [@chobbs](https://github.com/chobbs).
menu:
flux_0_x_ref:
name: chobbs
name: chobbs
parent: contrib
weight: 101
introduced: 0.69.0
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@chobbs](https://github.com/chobbs)
**InfluxDB Slack:** [@craig](https://influxdata.com/slack)
identifier: contrib/chobbs
weight: 21
---
The `chobbs` package contains functions and packages contributed by [@chobbs](https://github.com/chobbs).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/chobbs/chobbs.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `chobbs` package contains packages and functions contributed by [@chobbs](https://github.com/chobbs).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -1,47 +1,57 @@
---
title: Flux discord package
list_title: discord package
title: discord package
description: >
The Flux `discord` package provides functions for sending messages to [Discord](https://discord.com/).
Import the `contrib/chobbs/discord` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/discord/
- /influxdb/cloud/reference/flux/stdlib/contrib/discord/
The `discord` package provides functions for sending messages to [Discord](https://discord.com/).
menu:
flux_0_x_ref:
name: discord
parent: chobbs
weight: 201
flux/v0.x/tags: [functions, discord, package]
introduced: 0.69.0
name: discord
parent: contrib/chobbs
identifier: contrib/chobbs/discord
weight: 31
cascade:
introduced: 0.69.0
---
The Flux `discord` package provides functions for sending messages to [Discord](https://discord.com/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/chobbs/discord/discord.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `discord` package provides functions for sending messages to [Discord](https://discord.com/).
Import the `contrib/chobbs/discord` package:
```js
import "contrib/chobbs/discord"
```
## Options
The `contrib/chobbs/discord` package provides the following options:
```js
import "contrib/chobbs/discord"
option discord.discordURL = "https://discordapp.com/api/webhooks/"
```
### discordURL
### discordURL {data-type="string"}
Discord webhook URL.
`discordURL` is the Discord webhook URL.
Default is `https://discordapp.com/api/webhooks/`.
## Functions
{{< children type="functions" show="pages" >}}
{{% note %}}
#### Package author and maintainer
**Github:** [@chobbs](https://github.com/chobbs)
**InfluxDB Slack:** [@craig](https://influxdata.com/slack)
{{% /note %}}

View File

@ -1,80 +1,75 @@
---
title: discord.endpoint() function
description: >
The `discord.endpoint()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3)
`discord.endpoint()` sends a single message to a Discord channel using a
[Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3)
and data from table rows.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/discord/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/discord/endpoint/
menu:
flux_0_x_ref:
name: discord.endpoint
parent: discord
weight: 202
flux/v0.x/tags: [notification endpoints]
introduced: 0.74.0
parent: contrib/chobbs/discord
identifier: contrib/chobbs/discord/endpoint
weight: 301
---
The `discord.endpoint()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3)
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/chobbs/discord/discord.flux#L118-L139
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`discord.endpoint()` sends a single message to a Discord channel using a
[Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3)
and data from table rows.
```js
import "contrib/chobbs/discord"
discord.endpoint(
webhookToken: "mySuPerSecRetTokEn",
webhookID: "123456789",
username: "username",
avatar_url: "https://example.com/avatar_pic.jpg",
)
##### Function type signature
```js
(
username: A,
webhookID: string,
webhookToken: string,
?avatar_url: B,
) => (mapFn: (r: C) => {D with content: E}) => (<-tables: stream[C]) => stream[{C with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### webhookToken {data-type="string"}
### webhookToken
({{< req >}})
Discord [webhook token](https://discord.com/developers/docs/resources/webhook).
### webhookID {data-type="string"}
### webhookID
({{< req >}})
Discord [webhook ID](https://discord.com/developers/docs/resources/webhook).
### username {data-type="string"}
Override the Discord webhook's default username.
### avatar_url {data-type="string"}
Override the Discord webhook's default avatar.
## Usage
`discord.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### username
({{< req >}})
Override the Discord webhooks default username.
### mapFn {data-type="function"}
A function that builds the record used to generate the Discord webhook request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns a record that must include the
following field:
- `content`
### avatar_url
_For more information, see the [`discord.send() content` parameter](/flux/v0.x/stdlib/contrib/chobbs/discord/send/#content)._
Override the Discord webhooks default avatar.
## Examples
##### Send critical statuses to a Discord channel
```js
import "influxdata/influxdb/secrets"
import "contrib/chobbs/discord"
discordToken = secrets.get(key: "DISCORD_TOKEN")
endpoint = telegram.endpoint(webhookToken: discordToken, webhookID: "123456789", username: "critBot")
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(mapFn: (r) => ({content: "The status is critical!"}))()
```

View File

@ -1,55 +1,89 @@
---
title: discord.send() function
description: >
The `discord.send()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3).
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/discord/send/
- /influxdb/cloud/reference/flux/stdlib/contrib/discord/send/
`discord.send()` sends a single message to a Discord channel using a Discord webhook.
menu:
flux_0_x_ref:
name: discord.send
parent: discord
weight: 202
introduced: 0.69.0
parent: contrib/chobbs/discord
identifier: contrib/chobbs/discord/send
weight: 301
flux/v0.x/tags: [single notification]
---
The `discord.send()` function sends a single message to a Discord channel using
a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&amp?page=3).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/chobbs/discord/discord.flux#L51-L64
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`discord.send()` sends a single message to a Discord channel using a Discord webhook.
##### Function type signature
```js
import "contrib/chobbs/discord"
discord.send(
webhookToken: "mySuPerSecRetTokEn",
webhookID: "123456789",
username: "username",
content: "This is an example message",
avatar_url: "https://example.com/avatar_pic.jpg",
)
(
content: A,
username: B,
webhookID: string,
webhookToken: string,
?avatar_url: C,
) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### webhookToken {data-type="string"}
### webhookToken
({{< req >}})
Discord [webhook token](https://discord.com/developers/docs/resources/webhook).
### webhookID {data-type="string"}
### webhookID
({{< req >}})
Discord [webhook ID](https://discord.com/developers/docs/resources/webhook).
### username {data-type="string"}
Override the Discord webhook's default username.
### content {data-type="string"}
### username
({{< req >}})
Override the Discord webhooks default username.
### content
({{< req >}})
Message to send to Discord (2000 character limit).
### avatar_url {data-type="string"}
Override the Discord webhook's default avatar.
### avatar_url
Override the Discord webhooks default avatar.
## Examples
##### Send the last reported status to Discord
### Send the last reported status to Discord
```js
import "contrib/chobbs/discord"
import "influxdata/influxdb/secrets"
token = secrets.get(key: "DISCORD_TOKEN")
@ -70,8 +104,3 @@ discord.send(
)
```
{{% note %}}
#### Package author and maintainer
**Github:** [@chobbs](https://github.com/chobbs)
**InfluxDB Slack:** [@craig](https://influxdata.com/slack)
{{% /note %}}

View File

@ -1,25 +1,36 @@
---
title: Packages contributed by jsternberg
list_title: jsternberg package
title: jsternberg package
description: >
The `jsternberg` package contains functions and packages contributed by [@jsternberg](https://github.com/jsternberg).
The `jsternberg` package contains packages and functions contributed by [@jsternberg](https://github.com/jsternberg).
menu:
flux_0_x_ref:
name: jsternberg
name: jsternberg
parent: contrib
weight: 101
introduced: 0.77.0
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@jsternberg](https://github.com/jsternberg)
**InfluxDB Slack:** [@Jonathan Sternberg](https://influxdata.com/slack)
identifier: contrib/jsternberg
weight: 21
---
The `jsternberg` package contains functions and packages contributed by [@jsternberg](https://github.com/jsternberg).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/jsternberg.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `jsternberg` package contains packages and functions contributed by [@jsternberg](https://github.com/jsternberg).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -0,0 +1,51 @@
---
title: aggregate package
description: >
The `aggregate` package provides an API for computing multiple aggregates over multiple columns within the same table stream.
menu:
flux_0_x_ref:
name: aggregate
parent: contrib/jsternberg
identifier: contrib/jsternberg/aggregate
weight: 31
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `aggregate` package provides an API for computing multiple aggregates over multiple columns within the same table stream.
Import the `contrib/jsternberg/aggregate` package:
```js
import "contrib/jsternberg/aggregate"
```
## Constants
```js
aggregate.none
aggregate.null
```
- **aggregate.none** is a sentinel value for fill that will skip
emitting a row if there are no values for an interval.
- **aggregate.null** is a sentinel value for fill that will fill
in a null value if there were no values for an interval.
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,63 @@
---
title: aggregate.count() function
description: >
`aggregate.count()` constructs a count aggregate for the column.
menu:
flux_0_x_ref:
name: aggregate.count
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/count
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L157-L165
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.count()` constructs a count aggregate for the column.
##### Function type signature
```js
(
?column: A,
?fill: B,
) => {
reduce: (state: int, values: [E]) => int,
init: (values: [D]) => int,
fill: B,
compute: (state: C) => C,
column: A,
}
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column
Name of the column to aggregate.
### fill
When set, value to replace missing values.

View File

@ -0,0 +1,91 @@
---
title: aggregate.define() function
description: >
`aggregate.define()` constructs an aggregate function record.
menu:
flux_0_x_ref:
name: aggregate.define
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/define
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L104-L112
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.define()` constructs an aggregate function record.
##### Function type signature
```js
(
compute: A,
init: B,
reduce: C,
?fill: D,
) => (
?column: E,
?fill: F,
) => {
reduce: C,
init: B,
fill: F,
compute: A,
column: E,
}
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### init
({{< req >}})
Function to compute the initial state of the
output. This can return either the final aggregate or a
temporary state object that can be used to compute the
final aggregate. The `values` parameter will always be a
non-empty array of values from the specified column.
### reduce
({{< req >}})
Function that takes in another buffer of values
and the current state of the aggregate and computes
the updated state.
### compute
({{< req >}})
Function that takes the state and computes the final aggregate.
### fill
Value passed to `fill()`. If present, the fill value determines what
the aggregate does when there are no values.
This can either be a value or one of the predefined
identifiers, `null` or `none`.
This value must be the same type as the value return from
compute.

View File

@ -0,0 +1,63 @@
---
title: aggregate.max() function
description: >
`aggregate.max()` constructs a max aggregate or selector for the column.
menu:
flux_0_x_ref:
name: aggregate.max
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/max
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L136-L136
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.max()` constructs a max aggregate or selector for the column.
##### Function type signature
```js
(
?column: A,
?fill: B,
) => {
reduce: (state: D, values: [D]) => D,
init: (values: [D]) => D,
fill: B,
compute: (state: C) => C,
column: A,
} where D: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column
Name of the column to aggregate.
### fill
When set, value to replace missing values.

View File

@ -0,0 +1,63 @@
---
title: aggregate.mean() function
description: >
`aggregate.mean()` constructs a mean aggregate for the column.
menu:
flux_0_x_ref:
name: aggregate.mean
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/mean
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L172-L177
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.mean()` constructs a mean aggregate for the column.
##### Function type signature
```js
(
?column: A,
?fill: B,
) => {
reduce: (state: {G with sum: H, count: int}, values: [H]) => {sum: H, count: int},
init: (values: [F]) => {sum: F, count: int},
fill: B,
compute: (state: {C with sum: E, count: D}) => float,
column: A,
} where F: Numeric, H: Addable + Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column
Name of the column to aggregate.
### fill
When set, value to replace missing values.

View File

@ -0,0 +1,63 @@
---
title: aggregate.min() function
description: >
`aggregate.min()` constructs a min aggregate or selector for the column.
menu:
flux_0_x_ref:
name: aggregate.min
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/min
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L129-L129
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.min()` constructs a min aggregate or selector for the column.
##### Function type signature
```js
(
?column: A,
?fill: B,
) => {
reduce: (state: D, values: [D]) => D,
init: (values: [D]) => D,
fill: B,
compute: (state: C) => C,
column: A,
} where D: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column
Name of the column to aggregate.
### fill
When set, value to replace missing values.

View File

@ -0,0 +1,63 @@
---
title: aggregate.sum() function
description: >
`aggregate.sum()` constructs a sum aggregate for the column.
menu:
flux_0_x_ref:
name: aggregate.sum
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/sum
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L143-L150
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.sum()` constructs a sum aggregate for the column.
##### Function type signature
```js
(
?column: A,
?fill: B,
) => {
reduce: (state: E, values: [E]) => E,
init: (values: [D]) => D,
fill: B,
compute: (state: C) => C,
column: A,
} where D: Numeric, E: Addable + Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### column
Name of the column to aggregate.
### fill
When set, value to replace missing values.

View File

@ -0,0 +1,125 @@
---
title: aggregate.table() function
description: >
`aggregate.table()` will aggregate columns and create tables with a single
row containing the aggregated value.
menu:
flux_0_x_ref:
name: aggregate.table
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/table
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L49-L49
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.table()` will aggregate columns and create tables with a single
row containing the aggregated value.
##### Function type signature
```js
(<-tables: stream[B], columns: A) => stream[C] where A: Record, B: Record, C: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### tables
Input data. Default is piped-forward data (`<-`).
### columns
({{< req >}})
Columns to aggregate and which aggregate method to use.
Columns is a record where the key is a column name and the value is an aggregate record.
The aggregate record is composed of at least the following required attributes:
- **column**: Input column name (string).
- **init**: A function to compute the initial state of the
output. This can return either the final aggregate or a
temporary state object that can be used to compute the
final aggregate. The `values` parameter will always be a
non-empty array of values from the specified column.
For example: `(values) => state`.
- **reduce**: A function that takes in another buffer of values
and the current state of the aggregate and computes
the updated state.
For example: `(values, state) => state`.
- **compute**: A function that takes the state and computes the final
aggregate. For example, `(state) => value`.
- **fill**: The value passed to `fill()`. If present, the fill value
determines what the aggregate does when there are no values.
This can either be a value or one of the predefined
identifiers of `null` or `none`.
This value must be the same type as the value return from
`compute`.
## Examples
### Compute the min of a specific column
```js
import "sampledata"
import "contrib/jsternberg/aggregate"
sampledata.float()
|> aggregate.table(columns: {"min_bottom_degrees": aggregate.min(column: "_value")})
```
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
#### Input data
| *tag | min_bottom_degrees |
| ---- | ------------------- |
| t1 | -2.18 |
| *tag | min_bottom_degrees |
| ---- | ------------------- |
| t2 | -3.75 |
#### Output data
| _time | *tag | _value |
| -------------------- | ---- | ------- |
| 2021-01-01T00:00:00Z | t1 | -2.18 |
| 2021-01-01T00:00:10Z | t1 | 10.92 |
| 2021-01-01T00:00:20Z | t1 | 7.35 |
| 2021-01-01T00:00:30Z | t1 | 17.53 |
| 2021-01-01T00:00:40Z | t1 | 15.23 |
| 2021-01-01T00:00:50Z | t1 | 4.43 |
| _time | *tag | _value |
| -------------------- | ---- | ------- |
| 2021-01-01T00:00:00Z | t2 | 19.85 |
| 2021-01-01T00:00:10Z | t2 | 4.97 |
| 2021-01-01T00:00:20Z | t2 | -3.75 |
| 2021-01-01T00:00:30Z | t2 | 19.77 |
| 2021-01-01T00:00:40Z | t2 | 13.86 |
| 2021-01-01T00:00:50Z | t2 | 1.86 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -0,0 +1,84 @@
---
title: aggregate.window() function
description: >
`aggregate.window()` aggregates columns and create tables by
organizing incoming points into windows.
menu:
flux_0_x_ref:
name: aggregate.window
parent: contrib/jsternberg/aggregate
identifier: contrib/jsternberg/aggregate/window
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/aggregate/aggregate.flux#L66-L76
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`aggregate.window()` aggregates columns and create tables by
organizing incoming points into windows.
Each table will have two additional columns: start and stop.
These are the start and stop times for each interval.
It is not possible to use start or stop as destination column
names with this function. The start and stop columns are not
added to the group key.
##### Function type signature
```js
(
<-tables: stream[B],
columns: A,
every: duration,
?period: duration,
?time: string,
) => stream[C] where A: Record, B: Record, C: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### tables
Input data. Default is piped-forward data (`<-`).
### columns
({{< req >}})
Columns to aggregate and which aggregate method to use. See `aggregate.table()` for details.
### every
({{< req >}})
Duration between the start of each interval.
### time
Column name for the time input. Defaults to `_time` or `time` (whichever is earlier in the list of columns).
### period
Length of the interval. Defaults to the `every` duration.

View File

@ -1,27 +1,44 @@
---
title: Flux influxdb package (contributed)
list_title: influxdb package
title: influxdb package
description: >
The Flux `influxdb` package provides additional functions for querying data from InfluxDB.
Import the `contrib/jsternberg/influxdb` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/
- /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/
The `influxdb` package provides additional functions for querying data from InfluxDB.
menu:
flux_0_x_ref:
name: influxdb
identifier: contrib_influxdb
parent: jsternberg
weight: 201
flux/v0.x/tags: [functions, package, query]
introduced: 0.77.0
name: influxdb
parent: contrib/jsternberg
identifier: contrib/jsternberg/influxdb
weight: 31
cascade:
introduced: 0.77.0
---
The Flux `influxdb` package provides additional functions for querying data from InfluxDB.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/influxdb/influxdb.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `influxdb` package provides additional functions for querying data from InfluxDB.
Import the `contrib/jsternberg/influxdb` package:
```js
import "contrib/jsternberg/influxdb"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,137 @@
---
title: from() function
description: >
`from()` retrieves data from an InfluxDB bucket between the `start` and `stop` times.
menu:
flux_0_x_ref:
name: from
parent: contrib/jsternberg/influxdb
identifier: contrib/jsternberg/influxdb/from
weight: 301
flux/v0.x/tags: [inputs]
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/influxdb/influxdb.flux#L81-L109
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`from()` retrieves data from an InfluxDB bucket between the `start` and `stop` times.
This version of `from` is equivalent to `from() |> range()` in a single call.
##### Function type signature
```js
(
bucket: string,
start: A,
?host: string,
?org: string,
?stop: B,
?token: string,
) => stream[{
C with
_value: D,
_time: time,
_stop: time,
_start: time,
_measurement: string,
_field: string,
}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### bucket
({{< req >}})
Name of the bucket to query.
**InfluxDB 1.x or Enterprise**: Provide an empty string (`""`).
### start
({{< req >}})
Earliest time to include in results.
Results include points that match the specified start time.
Use a relative duration, absolute time, or integer (Unix timestamp in seconds).
For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`.
Durations are relative to `now()`.
### stop
Latest time to include in results. Default is `now()`.
Results exclude points that match the specified stop time.
Use a relative duration, absolute time, or integer (Unix timestamp in seconds).
For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`.
Durations are relative to `now()`.
### host
URL of the InfluxDB instance to query.
See [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/)
or [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/).
### org
Organization name.
### token
InfluxDB [API token](https://docs.influxdata.com/influxdb/latest/security/tokens/).
## Examples
- [Query using the bucket name](#query-using-the-bucket-name)
- [Query using the bucket ID](#query-using-the-bucket-id)
- [Query a remote InfluxDB Cloud instance](#query-a-remote-influxdb-cloud-instance)
### Query using the bucket name
```js
import "contrib/jsternberg/influxdb"
influxdb.from(bucket: "example-bucket")
```
### Query using the bucket ID
```js
import "contrib/jsternberg/influxdb"
influxdb.from(bucketID: "0261d8287f4d6000")
```
### Query a remote InfluxDB Cloud instance
```js
import "contrib/jsternberg/influxdb"
import "influxdata/influxdb/secrets"
token = secrets.get(key: "INFLUXDB_CLOUD_TOKEN")
from(bucket: "example-bucket", host: "https://us-west-2-1.aws.cloud2.influxdata.com", org: "example-org", token: token)
```

View File

@ -1,102 +1,137 @@
---
title: influxdb.select() function
description: >
The `influxdb.select()` function is an alternate implementation of `from()`, `range()`, `filter()`
and `pivot()` that returns pivoted query results and masks the `_start` and `_stop` column
Results are similar to those returned by InfluxQL `SELECT` statements.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/influxdb/select/
- /influxdb/cloud/reference/flux/stdlib/contrib/influxdb/select/
`influxdb.select()` is an alternate implementation of `from()`,
`range()`, `filter()` and `pivot()` that returns pivoted query results and masks
the `_measurement`, `_start`, and `_stop` columns. Results are similar to those
returned by InfluxQL `SELECT` statements.
menu:
flux_0_x_ref:
name: influxdb.select
parent: contrib_influxdb
parent: contrib/jsternberg/influxdb
identifier: contrib/jsternberg/influxdb/select
weight: 301
flux/v0.x/tags: [inputs]
related:
- /flux/v0.x/stdlib/influxdata/influxdb/from/
- /flux/v0.x/stdlib/universe/range/
- /flux/v0.x/stdlib/universe/filter/
- /flux/v0.x/stdlib/influxdata/influxdb/schema/fieldsascols/
- /flux/v0.x/stdlib/universe/pivot/
introduced: 0.77.0
---
The `influxdb.select()` function is an alternate implementation of `from()`, `range()`, `filter()`
and `pivot()` that returns pivoted query results and masks the `_measurement`, `_start`, and `_stop` columns.
Results are similar to those returned by InfluxQL `SELECT` statements.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/influxdb/influxdb.flux#L213-L262
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`influxdb.select()` is an alternate implementation of `from()`,
`range()`, `filter()` and `pivot()` that returns pivoted query results and masks
the `_measurement`, `_start`, and `_stop` columns. Results are similar to those
returned by InfluxQL `SELECT` statements.
##### Function type signature
```js
import "contrib/jsternberg/influxdb"
influxdb.select(
from: "example-bucket",
start: -1d,
stop: now(),
m: "example-measurement",
fields: [],
where: (r) => true,
host: "https://example.com",
org: "example-org",
token: "MySuP3rSecr3Tt0k3n",
)
(
from: string,
m: A,
start: B,
?fields: [string],
?host: string,
?org: string,
?stop: C,
?token: string,
?where: (
r: {
D with
_value: E,
_time: time,
_stop: time,
_start: time,
_measurement: string,
_field: string,
},
) => bool,
) => stream[F] where A: Equatable, F: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
{{% note %}}
[host](#host), [org](#org), and [token](#token) parameters are only required when
querying data from a **different organization** or a **remote InfluxDB instance**.
{{% /note %}}
### from
({{< req >}})
Name of the bucket to query.
### from {data-type="string"}
({{< req >}}) Name of the bucket to query.
### start {data-type="duration, time, int"}
({{< req >}}) Earliest time to include in results.
Results **include** points that match the specified start time.
### start
({{< req >}})
Earliest time to include in results.
Results include points that match the specified start time.
Use a relative duration, absolute time, or integer (Unix timestamp in seconds).
For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`.
Durations are relative to `now()`.
### stop {data-type="duration, time, int"}
Latest time to include in results.
Results **exclude** points that match the specified stop time.
### stop
Latest time to include in results. Default is `now()`.
Results exclude points that match the specified stop time.
Use a relative duration, absolute time, or integer (Unix timestamp in seconds).
For example, `-1h`, `2019-08-28T22:00:00Z`, or `1567029600`.
Durations are relative to `now()`.
Defaults to `now()`.
### m
({{< req >}})
Name of the measurement to query.
### m {data-type="string"}
({{< req >}}) Name of the measurement to query.
### fields {data-type="array of strings"}
List of fields to query.
Returns all fields when list is empty or unspecified.
Defaults to `[]`.
### where {data-type="function"}
A single argument predicate function that evaluates true or false and filters results based on tag values.
Records are passed to the function **before fields are pivoted into columns**.
Records that evaluate to true are included in the output tables.
Records that evaluate to _null_ or false are not included in the output tables.
Defaults to `(r) => true`.
### fields
{{% note %}}
Records evaluated in `fn` functions are represented by `r`, short for "record" or "row".
{{% /note %}}
List of fields to query. Default is`[]`.
_Returns all fields when list is empty or unspecified._
### where
Single argument predicate function that evaluates `true` or `false`
and filters results based on tag values.
Default is `(r) => true`.
Records are passed to the function before fields are pivoted into columns.
Records that evaluate to `true` are included in the output tables.
Records that evaluate to _null_ or `false` are not included in the output tables.
### host
### host {data-type="string"}
URL of the InfluxDB instance to query.
_See [InfluxDB URLs](/{{< latest "influxdb" >}}/reference/urls/)
or [InfluxDB Cloud regions](/{{< latest "influxdb" >}}/reference/regions/)._
### org {data-type="string"}
See [InfluxDB OSS URLs](https://docs.influxdata.com/influxdb/latest/reference/urls/)
or [InfluxDB Cloud regions](https://docs.influxdata.com/influxdb/cloud/reference/regions/).
### org
Organization name.
### token {data-type="string"}
InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/).
### token
InfluxDB [API token](https://docs.influxdata.com/influxdb/latest/security/tokens/).
## Examples
@ -105,21 +140,26 @@ InfluxDB [API token](/{{< latest "influxdb" >}}/security/tokens/).
- [Query all fields and filter by tags](#query-all-fields-and-filter-by-tags)
- [Query data from a remote InfluxDB Cloud instance](#query-data-from-a-remote-influxdb-cloud-instance)
##### Query a single field
### Query a single field
```js
import "contrib/jsternberg/influxdb"
influxdb.select(from: "example-bucket", start: -1d, m: "example-measurement", fields: ["field1"])
```
##### Query multiple fields
### Query multiple fields
```js
import "contrib/jsternberg/influxdb"
influxdb.select(from: "example-bucket", start: -1d, m: "example-measurement", fields: ["field1", "field2", "field3"])
```
##### Query all fields and filter by tags
### Query all fields and filter by tags
```js
import "contrib/jsternberg/influxdb"
@ -131,7 +171,9 @@ influxdb.select(
)
```
##### Query data from a remote InfluxDB Cloud instance
### Query data from a remote InfluxDB Cloud instance
```js
import "contrib/jsternberg/influxdb"
import "influxdata/influxdb/secrets"
@ -143,8 +185,9 @@ influxdb.select(
start: -1d,
m: "example-measurement",
fields: ["field1", "field2"],
host: "https://cloud2.influxdata.com",
host: "https://us-west-2-1.aws.cloud2.influxdata.com",
org: "example-org",
token: token,
)
```

View File

@ -0,0 +1,41 @@
---
title: math package
description: >
The `math` package provides implementations of aggregate functions.
menu:
flux_0_x_ref:
name: math
parent: contrib/jsternberg
identifier: contrib/jsternberg/math
weight: 31
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `math` package provides implementations of aggregate functions.
Import the `contrib/jsternberg/math` package:
```js
import "contrib/jsternberg/math"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,48 @@
---
title: math.max() function
description: >
`math.max()` returns the maximum value within the array.
menu:
flux_0_x_ref:
name: math.max
parent: contrib/jsternberg/math
identifier: contrib/jsternberg/math/max
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux#L31-L35
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`math.max()` returns the maximum value within the array.
##### Function type signature
```js
(values: [A]) => A where A: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### values
({{< req >}})
Array of values.

View File

@ -0,0 +1,48 @@
---
title: math.maxIndex() function
description: >
`math.maxIndex()` returns the index of the maximum value within the array.
menu:
flux_0_x_ref:
name: math.maxIndex
parent: contrib/jsternberg/math
identifier: contrib/jsternberg/math/maxIndex
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux#L25-L25
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`math.maxIndex()` returns the index of the maximum value within the array.
##### Function type signature
```js
(values: [A]) => int where A: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### values
({{< req >}})
Array of values.

View File

@ -0,0 +1,48 @@
---
title: math.min() function
description: >
`math.min()` returns the minimum value within the array.
menu:
flux_0_x_ref:
name: math.min
parent: contrib/jsternberg/math
identifier: contrib/jsternberg/math/min
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux#L15-L19
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`math.min()` returns the minimum value within the array.
##### Function type signature
```js
(values: [A]) => A where A: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### values
({{< req >}})
Array of values.

View File

@ -0,0 +1,48 @@
---
title: math.minIndex() function
description: >
`math.minIndex()` returns the index of the minimum value within the array.
menu:
flux_0_x_ref:
name: math.minIndex
parent: contrib/jsternberg/math
identifier: contrib/jsternberg/math/minIndex
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux#L9-L9
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`math.minIndex()` returns the index of the minimum value within the array.
##### Function type signature
```js
(values: [A]) => int where A: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### values
({{< req >}})
Array of values.

View File

@ -0,0 +1,48 @@
---
title: math.sum() function
description: >
`math.sum()` returns the sum of all values within the array.
menu:
flux_0_x_ref:
name: math.sum
parent: contrib/jsternberg/math
identifier: contrib/jsternberg/math/sum
weight: 301
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/jsternberg/math/math.flux#L41-L41
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`math.sum()` returns the sum of all values within the array.
##### Function type signature
```js
(values: [A]) => A where A: Numeric
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### values
({{< req >}})
Array of values.

View File

@ -1,26 +1,36 @@
---
title: Packages contributed by rhajek
list_title: rhajek package
title: rhajek package
description: >
The `rhajek` package contains functions and packages contributed by
[@rhajek](https://github.com/rhajek).
The `rhajek` package contains packages and functions contributed by [@rhajek](https://github.com/rhajek).
menu:
flux_0_x_ref:
name: rhajek
name: rhajek
parent: contrib
weight: 101
introduced: 0.108.0
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@rhajek](https://github.com/rhajek), [@bonitoo-io](https://github.com/bonitoo-io)
identifier: contrib/rhajek
weight: 21
---
The `rhajek` package contains functions and packages contributed by
[@rhajek](https://github.com/rhajek).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/rhajek.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `rhajek` package contains packages and functions contributed by [@rhajek](https://github.com/rhajek).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -1,58 +1,64 @@
---
title: Flux bigpanda package
list_title: bigpanda package
title: bigpanda package
description: >
The Flux `bigpanda` package provides functions that send alerts to
[BigPanda](https://www.bigpanda.io/).
The `bigpanda` package provides functions for sending alerts to [BigPanda](https://www.bigpanda.io/).
menu:
flux_0_x_ref:
name: bigpanda
parent: rhajek
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/
- /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/
flux/v0.x/tags: [functions, bigpanda, package]
name: bigpanda
parent: contrib/rhajek
identifier: contrib/rhajek/bigpanda
weight: 31
---
The Flux `bigpanda` package provides functions that send alerts to
[BigPanda](https://www.bigpanda.io/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/bigpanda/bigpanda.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `bigpanda` package provides functions for sending alerts to [BigPanda](https://www.bigpanda.io/).
Import the `contrib/rhajek/bigpanda` package:
```js
import "contrib/rhajek/bigpanda"
```
## Options
The BigPanda package provides the following options:
- [defaultURL](#defaulturl)
- [defaultTokenPrefix](#defaulttokenprefix)
## Options
```js
import "contrib/rhajek/bigpanda"
option bigpanda.defaultTokenPrefix = "Bearer"
option bigpanda.defaultUrl = "https://api.bigpanda.io/data/v2/alerts"
option bigpanda.defaultTokenPrefix = "Bearer"
```
### defaultTokenPrefix
### defaultUrl {data-type="string"}
The default [BigPanda alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works)
for functions in the BigPanda package.
Default is `https://api.bigpanda.io/data/v2/alerts`.
### defaultTokenPrefix {data-type="string"}
The default HTTP authentication schema to use when authenticating with BigPanda.
`defaultTokenPrefix` is the default HTTP authentication scheme to use when authenticating with BigPanda.
Default is `Bearer`.
### defaultUrl
`defaultUrl` is the default [BigPanda alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works)
for functions in the `bigpanda` package.
Default is `https://api.bigpanda.io/data/v2/alerts`.
## Functions
{{< children type="functions" show="pages" >}}
## Send alert timestamps to BigPanda
Sending alert timestamps to BigPanda is optional, but if you choose to send them,
convert timestamps to **epoch second timestamps**:
```js
data
|> map(fn: (r) => ({ r with secTime: int(v: r._time) / 1000000000 }))
```

View File

@ -1,87 +1,65 @@
---
title: bigpanda.endpoint() function
description: >
The `bigpanda.endpoint()` function sends alerts to BigPanda using data from input rows.
`bigpanda.endpoint()` sends alerts to BigPanda using data from input rows.
menu:
flux_0_x_ref:
name: bigpanda.endpoint
parent: bigpanda
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/endpoint/
flux/v0.x/tags: [notification endpoints]
introduced: 0.108.0
parent: contrib/rhajek/bigpanda
identifier: contrib/rhajek/bigpanda/endpoint
weight: 301
---
The `bigpanda.endpoint()` function sends alerts to [BigPanda](https://www.bigpanda.io/)
using data from input rows.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/bigpanda/bigpanda.flux#L206-L227
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`bigpanda.endpoint()` sends alerts to BigPanda using data from input rows.
##### Function type signature
```js
import "contrib/rhajek/bigpanda"
bigpanda.endpoint(
url: "https://api.bigpanda.io/data/v2/alerts",
token: "my5uP3rS3cRe7t0k3n",
appKey: "example-app-key",
)
(
appKey: A,
token: string,
?url: string,
) => (mapFn: (r: B) => {C with status: D}) => (<-tables: stream[B]) => stream[{B with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works).
Default is the value of the [`bigpanda.defaultURL` option](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/#defaulturl).
### url
### token {data-type="string"}
BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works).
Default is the value of the `bigpanda.defaultURL` option.
### token
({{< req >}})
BigPanda [API Authorization token (API key)](https://docs.bigpanda.io/docs/api-key-management).
### appKey {data-type="string"}
### appKey
({{< req >}})
BigPanda [App Key](https://docs.bigpanda.io/reference#integrating-monitoring-systems).
## Usage
`bigpanda.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `status`
- Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object)
to send to the BigPanda alert API.
_For more information, see [`bigpanda.sendAlert()` parameters](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/sendalert/#parameters)._
## Examples
##### Send critical alerts to BigPanda
```js
import "contrib/rhajek/bigpanda"
import "influxdata/influxdb/secrets"
import "json"
token = secrets.get(key: "BIGPANDA_API_KEY")
endpoint = bigpanda.endpoint(token: token, appKey: "example-app-key")
crit_events =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_events
|> endpoint(
mapFn: (r) => {
return {r with status: "critical",
check: "critical-status-check",
description: "${r._field} is critical: ${string(v: r._value)}",
tags: json.encode(v: [{"name": "host", "value": r.host}]),
}
},
)()
```

View File

@ -1,65 +1,92 @@
---
title: bigpanda.sendAlert() function
description: >
The `bigpanda.sendAlert()` function sends an alert to BigPanda.
`bigpanda.sendAlert()` sends an alert to [BigPanda](https://www.bigpanda.io/).
menu:
flux_0_x_ref:
name: bigpanda.sendAlert
parent: bigpanda
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/sendAlert/
- /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/sendAlert/
introduced: 0.108.0
parent: contrib/rhajek/bigpanda
identifier: contrib/rhajek/bigpanda/sendAlert
weight: 301
flux/v0.x/tags: [single notification]
---
The `bigpanda.sendAlert()` function sends an alert to [BigPanda](https://www.bigpanda.io/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/bigpanda/bigpanda.flux#L137-L149
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`bigpanda.sendAlert()` sends an alert to [BigPanda](https://www.bigpanda.io/).
##### Function type signature
```js
import "contrib/rhajek/bigpanda"
bigpanda.sendAlert(
url: "https://api.bigpanda.io/data/v2/alerts",
token: "my5uP3rS3cRe7t0k3n",
appKey: "example-app-key",
status: "critical",
rec: {},
)
(
appKey: A,
rec: B,
status: C,
token: string,
url: string,
) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
BigPanda [alerts API URL](https://docs.bigpanda.io/reference#alerts-how-it-works).
Default is the value of the [`bigpanda.defaultURL` option](/flux/v0.x/stdlib/contrib/rhajek/bigpanda/#defaulturl).
Default is the value of the `bigpanda.defaultURL` option.
### token {data-type="string"}
### token
({{< req >}})
BigPanda [API Authorization token (API key)](https://docs.bigpanda.io/docs/api-key-management).
### appKey {data-type="string"}
### appKey
({{< req >}})
BigPanda [App Key](https://docs.bigpanda.io/reference#integrating-monitoring-systems).
### status {data-type="string"}
### status
({{< req >}})
BigPanda [alert status](https://docs.bigpanda.io/reference#alerts).
**Supported statuses:**
Supported statuses:
- `ok`
- `critical`
- `warning`
- `acknowledged`
### rec {data-type="record"}
### rec
({{< req >}})
Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object)
to send to the BigPanda alert API.
Additional [alert parameters](https://docs.bigpanda.io/reference#alert-object) to send to the BigPanda alert API.
## Examples
##### Send the last reported value and status to BigPanda
### Send the last reported value and status to BigPanda
```js
import "contrib/rhajek/bigpanda"
import "influxdata/influxdb/secrets"
@ -85,3 +112,4 @@ bigpanda.sendAlert(
},
)
```

View File

@ -1,41 +1,106 @@
---
title: bigpanda.statusFromLevel() function
description: >
The `bigpanda.statusFromLevel()` function converts an alert level into a BigPanda status.
`bigpanda.statusFromLevel()` converts an alert level to a BigPanda status.
menu:
flux_0_x_ref:
name: bigpanda.statusFromLevel
parent: bigpanda
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/
- /influxdb/cloud/reference/flux/stdlib/contrib/bigpanda/statusfromlevel/
introduced: 0.108.0
parent: contrib/rhajek/bigpanda
identifier: contrib/rhajek/bigpanda/statusFromLevel
weight: 301
---
The `bigpanda.statusFromLevel()` function converts an alert level into a BigPanda status.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/rhajek/bigpanda/bigpanda.flux#L70-L85
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`bigpanda.statusFromLevel()` converts an alert level to a BigPanda status.
BigPanda accepts one of ok, warning, or critical,.
##### Function type signature
```js
import "contrib/rhajek/bigpanda"
bigpanda.statusFromLevel(level: "crit")
// Returns "critical"
(level: string) => string
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### level {data-type="string"}
### level
({{< req >}})
Alert level.
##### Supported alert levels
| Alert level | BigPanda status |
|:-----------:|:---------------:|
| :---------- | :--------------|
| crit | critical |
| warn | warning |
| info | ok |
| ok | ok |
_All other alert levels return a `critical` BigPanda status._
## Examples
- [Convert an alert level to a BigPanda status](#convert-an-alert-level-to-a-bigpanda-status)
- [Convert alert levels in a stream of tables to BigPanda statuses](#convert-alert-levels-in-a-stream-of-tables-to-bigpanda-statuses)
### Convert an alert level to a BigPanda status
```js
import "contrib/rhajek/bigpanda"
bigpanda.statusFromLevel(level: "crit")// Returns "critical"
```
### Convert alert levels in a stream of tables to BigPanda statuses
Use `map()` to iterate over rows in a stream of tables and convert alert levels to Big Panda statuses.
```js
import "contrib/rhajek/bigpanda"
data
|> map(fn: (r) => ({r with big_panda_status: bigpanda.statusFromLevel(level: r._level)}))
```
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
#### Input data
| _time | _level |
| -------------------- | ------- |
| 2021-01-01T00:00:00Z | ok |
| 2021-01-01T00:01:00Z | info |
| 2021-01-01T00:02:00Z | warn |
| 2021-01-01T00:03:00Z | crit |
#### Output data
| _level | _time | big_panda_status |
| ------- | -------------------- | ----------------- |
| ok | 2021-01-01T00:00:00Z | ok |
| info | 2021-01-01T00:01:00Z | ok |
| warn | 2021-01-01T00:02:00Z | warning |
| crit | 2021-01-01T00:03:00Z | critical |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,27 +1,36 @@
---
title: Packages contributed by sranka
list_title: sranka package
title: sranka package
description: >
The `sranka` package contains functions and packages contributed by
[@sranka](https://github.com/sranka).
The `sranka` package contains packages and functions contributed by [@sranka](https://github.com/sranka).
menu:
flux_0_x_ref:
name: sranka
name: sranka
parent: contrib
weight: 101
introduced: 0.70.0
cascade:
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@sranka](https://github.com/sranka)
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
identifier: contrib/sranka
weight: 21
---
The `sranka` package contains functions and packages contributed by
[@sranka](https://github.com/sranka).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/sranka.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `sranka` package contains packages and functions contributed by [@sranka](https://github.com/sranka).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -1,30 +1,48 @@
---
title: Flux opsgenie package
list_title: opsgenie package
title: opsgenie package
description: >
The Flux `opsgenie` package provides functions that send alerts to
[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) using the
[Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert).
Import the `contrib/sranka/opsgenie` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/
- /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/
The `opsgenie` package provides functions that send alerts to
[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie)
using the [Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert).
menu:
flux_0_x_ref:
name: opsgenie
parent: sranka
weight: 201
flux/v0.x/tags: [functions, opsgenie, package]
introduced: 0.84.0
name: opsgenie
parent: contrib/sranka
identifier: contrib/sranka/opsgenie
weight: 31
cascade:
introduced: 0.84.0
---
The Flux `opsgenie` package provides functions that send alerts to
[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie) using the
[Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/opsgenie/opsgenie.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `opsgenie` package provides functions that send alerts to
[Atlassian Opsgenie](https://www.atlassian.com/software/opsgenie)
using the [Opsgenie v2 API](https://docs.opsgenie.com/docs/alert-api#create-alert).
Import the `contrib/sranka/opsgenie` package:
```js
import "contrib/sranka/opsgenie"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,96 +1,79 @@
---
title: opsgenie.endpoint() function
description: >
The `opsgenie.endpoint()` function sends an alert message to Opsgenie using data from table rows.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/endpoint/
`opsgenie.endpoint()` sends an alert message to Opsgenie using data from table rows.
menu:
flux_0_x_ref:
name: opsgenie.endpoint
parent: opsgenie
parent: contrib/sranka/opsgenie
identifier: contrib/sranka/opsgenie/endpoint
weight: 301
flux/v0.x/tags: [notification endpoints]
introduced: 0.84.0
---
The `opsgenie.endpoint()` function sends an alert message to Opsgenie using data from table rows.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/opsgenie/opsgenie.flux#L176-L204
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`opsgenie.endpoint()` sends an alert message to Opsgenie using data from table rows.
##### Function type signature
```js
import "contrib/sranka/opsgenie"
opsgenie.endpoint(
url: "https://api.opsgenie.com/v2/alerts",
apiKey: "YoUrSup3R5ecR37AuThK3y",
entity: "example-entity",
)
(
apiKey: string,
?entity: string,
?url: string,
) => (
mapFn: (
r: A,
) => {
B with
visibleTo: [string],
tags: E,
responders: [string],
priority: string,
message: string,
details: D,
description: string,
alias: string,
actions: C,
},
) => (<-tables: stream[A]) => stream[{A with _sent: string}] where D: Stringable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
Opsgenie API URL.
Defaults to `https://api.opsgenie.com/v2/alerts`.
### url
### apiKey {data-type="string"}
Opsgenie API URL. Defaults to `https://api.opsgenie.com/v2/alerts`.
### apiKey
({{< req >}})
Opsgenie API authorization key.
(Required) Opsgenie API authorization key.
### entity
### entity {data-type="string"}
Alert entity used to specify the alert domain.
## Usage
`opsgenie.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the record used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns a record that must include the
following fields:
- `message`
- `alias`
- `description`
- `priority`
- `responders`
- `tags`
- `actions`
- `details`
- `visibleTo`
_For more information, see [`opsgenie.sendAlert()`](/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert/)._
## Examples
##### Send critical statuses to Opsgenie
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/opsgenie"
apiKey = secrets.get(key: "OPSGENIE_APIKEY")
endpoint = opsgenie.endpoint(apiKey: apiKey)
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(
mapFn: (r) =>
({
message: "Great Scott!- Disk usage is: ${r.status}.",
alias: "disk-usage-${r.status}",
description: "",
priority: "P3",
responders: ["user:john@example.com", "team:itcrowd"],
tags: [],
entity: "my-lab",
actions: [],
details: "{}",
visibleTo: [],
}),
)()
```

View File

@ -1,40 +1,52 @@
---
title: opsgenie.respondersToJSON() function
description: >
The `opsgenie.respondersToJSON()` function converts an array of
[Opsgenie responder](https://docs.opsgenie.com/docs/alert-recipients-and-teams)
strings to a string-encoded JSON array that can be embedded in an alert message.
`opsgenie.respondersToJSON()` converts an array of Opsgenie responder strings
to a string-encoded JSON array that can be embedded in an alert message.
menu:
flux_0_x_ref:
name: opsgenie.respondersToJSON
parent: opsgenie
parent: contrib/sranka/opsgenie
identifier: contrib/sranka/opsgenie/respondersToJSON
weight: 301
introduced: 0.84.0
---
The `opsgenie.respondersToJSON()` function converts an array of
[Opsgenie responder](https://docs.opsgenie.com/docs/alert-recipients-and-teams)
strings to a string-encoded JSON array that can be embedded in an alert message.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/opsgenie/opsgenie.flux#L21-L21
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`opsgenie.respondersToJSON()` converts an array of Opsgenie responder strings
to a string-encoded JSON array that can be embedded in an alert message.
##### Function type signature
```js
import "contrib/sranka/opsgenie"
import "contrib/sranka/opsgenie"
opsgenie.respondersToJSON(
v: ["user:example-user", "team:example-team", "escalation:example-escalation", "schedule:example-schedule"],
)
// Returns "[
// {"type":"user","username":"example-user"},
// {"type":"team","name":"example-team"},
// {"type":"escalation","name":"example-escalation"},
// {"type":"schedule","name":"example-schedule"}
// ]"
(v: [string]) => string
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v {data-type="array of strings"}
({{< req >}}) Array of Opsgenie responder strings.
Responder strings must begin with `user:`, `team:`, `escalation:`, or `schedule:`.
### v
({{< req >}})
(Required) Array of Opsgenie responder strings.
Responder strings must begin with
`user: `, `team: `, `escalation: `, or `schedule: `.

View File

@ -1,97 +1,146 @@
---
title: opsgenie.sendAlert() function
description: >
The `opsgenie.sendAlert()` function sends an alert message to Opsgenie.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/opsgenie/sendalert/
- /influxdb/cloud/reference/flux/stdlib/contrib/opsgenie/sendalert/
`opsgenie.sendAlert()` sends an alert message to Opsgenie.
menu:
flux_0_x_ref:
name: opsgenie.sendAlert
parent: opsgenie
parent: contrib/sranka/opsgenie
identifier: contrib/sranka/opsgenie/sendAlert
weight: 301
introduced: 0.84.0
flux/v0.x/tags: [single notification]
---
The `opsgenie.sendAlert()` function sends an alert message to Opsgenie.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/opsgenie/opsgenie.flux#L76-L115
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`opsgenie.sendAlert()` sends an alert message to Opsgenie.
##### Function type signature
```js
import "contrib/sranka/opsgenie"
opsgenie.sendAlert(
url: "https://api.opsgenie.com/v2/alerts",
apiKey: "YoUrSup3R5ecR37AuThK3y",
message: "Example message",
alias: "Example alias",
description: "Example description",
priority: "P3",
responders: ["user:john@example.com", "team:itcrowd"],
tags: ["tag1", "tag2"],
entity: "example-entity",
actions: ["action1", "action2"],
details: "{}",
visibleTo: [],
)
(
apiKey: string,
message: string,
?actions: A,
?alias: string,
?description: string,
?details: B,
?entity: string,
?priority: string,
?responders: [string],
?tags: C,
?url: string,
?visibleTo: [string],
) => int where B: Stringable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
Opsgenie API URL.
Defaults to `https://api.opsgenie.com/v2/alerts`.
### url
### apiKey {data-type="string"}
({{< req >}})
Opsgenie API authorization key.
Opsgenie API URL. Defaults to `https://api.opsgenie.com/v2/alerts`.
### message {data-type="string"}
### apiKey
({{< req >}})
Alert message text.
(Required) Opsgenie API authorization key.
### message
({{< req >}})
(Required) Alert message text.
130 characters or less.
### alias {data-type="string"}
### alias
Opsgenie alias usee to de-deduplicate alerts.
250 characters or less.
Defaults to [message](#message).
Defaults to [message](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/opsgenie/sendalert/#message).
### description {data-type="string"}
Alert description.
15000 characters or less.
### priority {data-type="string"}
Opsgenie [alert priority](https://docs.opsgenie.com/docs/alert-priority-settings).
### description
Alert description. 15000 characters or less.
### priority
Opsgenie alert priority.
Valid values include:
- `P1`
- `P2`
- `P3` _(default)_
- `P3` (default)
- `P4`
- `P5`
### responders {data-type="array of strings"}
List of responder teams or users.
Use the `user:` prefix for users and `teams:` prefix for teams.
### responders
List of responder teams or users.
Use the `user: ` prefix for users and `teams: ` prefix for teams.
### tags
### tags {data-type="array of strings"}
Alert tags.
### entity {data-type="string"}
### entity
Alert entity used to specify the alert domain.
### actions {data-type="array of strings"}
### actions
List of actions available for the alert.
### details {data-type="string"}
Additional alert details.
Must be a JSON-encoded map of key-value string pairs.
### visibleTo {data-type="array of strings"}
### details
Additional alert details. Must be a JSON-encoded map of key-value string pairs.
### visibleTo
List of teams and users the alert will be visible to without sending notifications.
Use the `user:` prefix for users and `teams:` prefix for teams.
Use the `user: ` prefix for users and `teams: ` prefix for teams.
## Examples
##### Send the last reported status to a Opsgenie
### Send the last reported status to a Opsgenie
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/opsgenie"
@ -112,3 +161,4 @@ opsgenie.sendAlert(
responders: ["user:john@example.com", "team:itcrowd"],
)
```

View File

@ -1,35 +1,48 @@
---
title: Flux sensu package
list_title: sensu package
title: sensu package
description: >
The Flux `sensu` package provides functions for sending events to
[Sensu Go](https://docs.sensu.io/sensu-go/latest/).
Import the `contrib/sranka/sensu` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/
- /influxdb/cloud/reference/flux/stdlib/contrib/sensu/
The `sensu` package provides functions for sending events to [Sensu Go](https://docs.sensu.io/sensu-go/latest/).
menu:
flux_0_x_ref:
name: sensu
parent: sranka
weight: 201
v2.0/tags: [functions, teams, sensu, package]
introduced: 0.90.0
name: sensu
parent: contrib/sranka
identifier: contrib/sranka/sensu
weight: 31
cascade:
introduced: 0.90.0
---
The Flux `sensu` package provides functions for sending events to
[Sensu Go](https://docs.sensu.io/sensu-go/latest/).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/sensu/sensu.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `sensu` package provides functions for sending events to [Sensu Go](https://docs.sensu.io/sensu-go/latest/).
Import the `contrib/sranka/sensu` package:
```js
import "contrib/sranka/sensu"
```
{{< children type="functions" show="pages" >}}
## Sensu API Key authentication
The Flux Sensu package only supports [Sensu API key authentication](https://docs.sensu.io/sensu-go/latest/api/#authenticate-with-an-api-key).
All `sensu` functions require an `apiKey` parameter to successfully authenticate
with your Sensu service.
For information about managing Sensu API keys, see the
[Sensu APIKeys API documentation](https://docs.sensu.io/sensu-go/latest/api/apikeys/).
All `sensu` functions require an `apiKey` parameter to successfully authenticate with your Sensu service.
For information about managing Sensu API keys, see the [Sensu APIKeys API documentation](https://docs.sensu.io/sensu-go/latest/api/apikeys/).
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,98 +1,90 @@
---
title: sensu.endpoint() function
description: >
The `sensu.endpoint()` function sends an event to the
[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event)
`sensu.endpoint()` sends an event
to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event)
using data from table rows.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/sensu/endpoint/
menu:
flux_0_x_ref:
name: sensu.endpoint
parent: sensu
parent: contrib/sranka/sensu
identifier: contrib/sranka/sensu/endpoint
weight: 301
related:
- https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API
- https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API
- https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers
flux/v0.x/tags: [notification endpoints]
introduced: 0.90.0
---
The `sensu.endpoint()` function sends an event to the
[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event)
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/sensu/sensu.flux#L199-L229
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`sensu.endpoint()` sends an event
to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event)
using data from table rows.
```js
import "contrib/sranka/sensu"
sensu.endpoint(
url: "http://localhost:8080",
apiKey: "mYSuP3rs3cREtApIK3Y",
handlers: [],
namespace: "default",
entityName: "influxdb",
)
##### Function type signature
```js
(
apiKey: string,
url: string,
?entityName: string,
?handlers: A,
?namespace: string,
) => (
mapFn: (r: B) => {C with text: E, status: D, checkName: string},
) => (<-tables: stream[B]) => stream[{B with _sent: string}] where D: Equatable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Base URL of [Sensu API](https://docs.sensu.io/sensu-go/latest/migrate/#architecture)
**without a trailing slash**. Example: `http://localhost:8080`.
*without a trailing slash*.
Example: `http://localhost:8080`.
### apiKey {data-type="string"}
### apiKey
({{< req >}})
Sensu [API Key](https://docs.sensu.io/sensu-go/latest/operations/control-access/).
### handlers {data-type="array of strings"}
### handlers
[Sensu handlers](https://docs.sensu.io/sensu-go/latest/reference/handlers/) to execute.
Default is `[]`.
### namespace {data-type="string"}
### namespace
[Sensu namespace](https://docs.sensu.io/sensu-go/latest/reference/rbac/).
Default is `default`.
### entityName {data-type="string"}
### entityName
Event source.
Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`).
All other characters are replaced with an underscore.
Default is `influxdb`.
## Usage
`sensu.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`).
All other characters are replaced with an underscore.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `checkName`
- `text`
- `status`
_For more information, see [`sensu.event()` parameters](/v2.0/reference/flux/stdlib/contrib/sensu/event/#parameters)._
## Examples
##### Send critical status events to Sensu
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/sensu"
token = secrets.get(key: "TELEGRAM_TOKEN")
endpoint = sensu.endpoint(url: "http://localhost:8080", apiKey: apiKey)
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(mapFn: (r) => ({checkName: "critStatus", text: "Status is critical", status: 2}))()
```

View File

@ -1,102 +1,130 @@
---
title: sensu.event() function
description: >
The `sensu.event()` function sends a single event to the
[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event).
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/sensu/event/
- /influxdb/cloud/reference/flux/stdlib/contrib/sensu/event/
`sensu.event()` sends a single event to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event).
menu:
flux_0_x_ref:
name: sensu.event
parent: sensu
parent: contrib/sranka/sensu
identifier: contrib/sranka/sensu/event
weight: 301
related:
- https://docs.sensu.io/sensu-go/latest/api/events/, Sensu Events API
- https://docs.sensu.io/sensu-go/latest/api/apikeys/, Sensu APIKeys API
- https://docs.sensu.io/sensu-go/latest/reference/handlers/, Sensu handlers
introduced: 0.90.0
flux/v0.x/tags: [single notification]
---
The `sensu.event()` function sends a single event to the
[Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/sensu/sensu.flux#L107-L135
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`sensu.event()` sends a single event to the [Sensu Events API](https://docs.sensu.io/sensu-go/latest/api/events/#create-a-new-event).
##### Function type signature
```js
import "contrib/sranka/sensu"
sensu.event(
url: "http://localhost:8080",
apiKey: "mYSuP3rs3cREtApIK3Y",
checkName: "checkName",
text: "Event output text",
handlers: [],
status: 0,
state: "passing",
namespace: "default",
entityName: "influxdb",
)
(
apiKey: string,
checkName: string,
text: A,
url: string,
?entityName: string,
?handlers: B,
?namespace: string,
?state: string,
?status: C,
) => int where C: Equatable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Base URL of [Sensu API](https://docs.sensu.io/sensu-go/latest/migrate/#architecture)
**without a trailing slash**. Example: `http://localhost:8080`.
without a trailing slash.
### apiKey {data-type="string"}
Example: `http://localhost:8080`
### apiKey
({{< req >}})
Sensu [API Key](https://docs.sensu.io/sensu-go/latest/operations/control-access/).
### checkName {data-type="string"}
### checkName
({{< req >}})
Check name.
Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`).
All other characters are replaced with an underscore.
### text {data-type="string"}
### text
({{< req >}})
Event text.
Mapped to `output` in the Sensu Events API request.
### handlers {data-type="array of strings"}
[Sensu handlers](https://docs.sensu.io/sensu-go/latest/reference/handlers/) to execute.
Default is `[]`.
### handlers
### status {data-type="int"}
Event status code that indicates [state](#state).
Sensu handlers to execute. Default is `[]`.
### status
Event status code that indicates [state](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/sensu/event/#state).
Default is `0`.
| Status code | State |
|:----------- |:----- |
| `0` | OK |
| `1` | WARNING |
| `2` | CRITICAL |
| :-------------- | :---------------------- |
| 0 | OK |
| 1 | WARNING |
| 2 | CRITICAL |
| Any other value | UNKNOWN or custom state |
### state {data-type="string"}
### state
Event state.
Default is `"passing"` for `0` [status](#status) and `"failing"` for other statuses.
The following values are accepted:
Default is `"passing"` for `0` [status](https://docs.influxdata.com/flux/v0.x/stdlib/contrib/sranka/sensu/event/#status) and `"failing"` for other statuses.
**Accepted values**:
- `"failing"`
- `"passing"`
- `"flapping"`
### namespace {data-type="string"}
### namespace
[Sensu namespace](https://docs.sensu.io/sensu-go/latest/reference/rbac/).
Default is `"default"`.
### entityName {data-type="string"}
### entityName
Event source.
Default is `influxdb`.
Use alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`).
All other characters are replaced with an underscore.
Default is `influxdb`.
## Examples
##### Send the last reported status to Sensu
### Send the last reported status to Sensu
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/sensu"
@ -117,3 +145,4 @@ sensu.event(
text: "Disk usage is **${lastReported.status}**.",
)
```

View File

@ -1,29 +1,62 @@
---
title: sensu.toSensuName() function
description: >
The `sensu.toSensuName()` function translates a string value to a Sensu name by
replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`).
`sensu.toSensuName()` translates a string value to a Sensu name
by replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`).
menu:
flux_0_x_ref:
name: sensu.toSensuName
parent: sensu
parent: contrib/sranka/sensu
identifier: contrib/sranka/sensu/toSensuName
weight: 301
introduced: 0.90.0
---
The `sensu.toSensuName()` function translates a string value to a Sensu name by
replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/sensu/sensu.flux#L34-L34
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`sensu.toSensuName()` translates a string value to a Sensu name
by replacing non-alphanumeric characters (`[a-zA-Z0-9_.-]`) with underscores (`_`).
##### Function type signature
```js
(v: string) => string
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### v
({{< req >}})
String to operate on.
## Examples
### Convert a string into a Sensu name
```js
import "contrib/sranka/sensu"
sensu.toSensuName(v: "Example string 1.2?")
sensu.toSensuName(v: "Example name conversion")// Returns "Example_name_conversion"
// Returns "Example_string_1.2_"
```
## Parameters
### v {data-type="string"}
({{< req >}})
String to operate on.

View File

@ -1,25 +1,38 @@
---
title: Flux Microsoft Teams package
list_title: teams package
title: teams package
description: >
The Flux `teams` (Microsoft Teams) package provides functions for sending messages to a
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
The `teams` package (Microsoft Teams) provides functions
for sending messages to a [Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
Import the `contrib/sranka/teams` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/teams/
- /influxdb/cloud/reference/flux/stdlib/contrib/teams/
menu:
flux_0_x_ref:
name: teams
parent: sranka
weight: 201
flux/v0.x/tags: [functions, teams, microsoft, package]
introduced: 0.70.0
name: teams
parent: contrib/sranka
identifier: contrib/sranka/teams
weight: 31
cascade:
introduced: 0.70.0
---
The Flux `teams` (Microsoft Teams) package provides functions for sending messages to a
[Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/teams/teams.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `teams` package (Microsoft Teams) provides functions
for sending messages to a [Microsoft Teams](https://www.microsoft.com/microsoft-365/microsoft-teams/group-chat-software)
channel using an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
Import the `contrib/sranka/teams` package:
@ -27,17 +40,21 @@ Import the `contrib/sranka/teams` package:
import "contrib/sranka/teams"
```
## Options
The `contrib/sranka/teams` package provides the following options:
```js
import "contib/sranka/teams"
option teams.summaryCutoff = 70
```
### summaryCutoff
`summaryCutoff` is the limit for message summaries.
Default is `70`.
### summaryCutoff {data-type="int"}
Character limit for message summaries. Default is `70`.
## Functions

View File

@ -1,68 +1,52 @@
---
title: teams.endpoint() function
description: >
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
using data from table rows.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/teams/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/teams/endpoint/
`teams.endpoint()` sends a message to a Microsoft Teams channel using data from table rows.
menu:
flux_0_x_ref:
name: teams.endpoint
parent: teams
weight: 202
flux/v0.x/tags: [notification endpoints]
introduced: 0.70.0
parent: contrib/sranka/teams
identifier: contrib/sranka/teams/endpoint
weight: 301
---
The `teams.endpoint()` function sends a message to a Microsoft Teams channel
using data from table rows.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/teams/teams.flux#L124-L144
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`teams.endpoint()` sends a message to a Microsoft Teams channel using data from table rows.
##### Function type signature
```js
import "contrib/sranka/teams"
teams.endpoint(url: "https://outlook.office.com/webhook/example-webhook")
(
url: string,
) => (
mapFn: (r: A) => {B with title: C, text: string, summary: string},
) => (<-tables: stream[A]) => stream[{A with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Incoming webhook URL.
## Usage
`teams.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `title`
- `text`
- `summary`
_For more information, see [`teams.message()` parameters](/v2.0/reference/flux/stdlib/contrib/teams/message/#parameters)._
## Examples
##### Send critical statuses to a Microsoft Teams channel
```js
import "contrib/sranka/teams"
url = "https://outlook.office.com/webhook/example-webhook"
endpoint = teams.endpoint(url: url)
crit_statuses =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses" and status == "crit")
crit_statuses
|> endpoint(
mapFn: (r) =>
({title: "Disk Usage", text: "Disk usage is: **${r.status}**.", summary: "Disk usage is ${r.status}"}),
)()
```

View File

@ -1,52 +1,78 @@
---
title: teams.message() function
description: >
The `teams.message()` function sends a single message to a Microsoft Teams channel using
an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/teams/message/
- /influxdb/cloud/reference/flux/stdlib/contrib/teams/message/
`teams.message()` sends a single message to a Microsoft Teams channel using an
[incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
menu:
flux_0_x_ref:
name: teams.message
parent: teams
weight: 202
introduced: 0.70.0
parent: contrib/sranka/teams
identifier: contrib/sranka/teams/message
weight: 301
flux/v0.x/tags: [single notification]
---
The `teams.message()` function sends a single message to a Microsoft Teams channel using
an [incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/teams/teams.flux#L53-L77
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`teams.message()` sends a single message to a Microsoft Teams channel using an
[incoming webhook](https://docs.microsoft.com/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
##### Function type signature
```js
import "contrib/sranka/teams"
teams.message(
url: "https://outlook.office.com/webhook/example-webhook",
title: "Example message title",
text: "Example message text",
summary: "",
)
(text: string, title: A, url: string, ?summary: string) => int
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
### url
({{< req >}})
Incoming webhook URL.
### title {data-type="string"}
### title
({{< req >}})
Message card title.
### text {data-type="string"}
### text
({{< req >}})
Message card text.
### summary {data-type="string"}
### summary
Message card summary.
Default is `""`.
If no summary is provided, Flux generates the summary from the message text.
## Examples
##### Send the last reported status to a Microsoft Teams channel
### Send the last reported status to a Microsoft Teams channel
```js
import "contrib/sranka/teams"
@ -64,3 +90,4 @@ teams.message(
summary: "Disk usage is ${lastReported.status}",
)
```

View File

@ -1,65 +1,49 @@
---
title: Flux telegram package
list_title: telegram package
title: telegram package
description: >
The Flux `telegram` package provides functions for sending messages to
[Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api).
Import the `contrib/sranka/telegram` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/
- /influxdb/cloud/reference/flux/stdlib/contrib/telegram/
The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/)
using the [Telegram Bot API](https://core.telegram.org/bots/api).
menu:
flux_0_x_ref:
name: telegram
parent: sranka
weight: 202
v2.0/tags: [functions, teams, telegram, package]
introduced: 0.70.0
name: telegram
parent: contrib/sranka
identifier: contrib/sranka/telegram
weight: 31
cascade:
introduced: 0.70.0
---
The Flux `telegram` package provides functions for sending messages to
[Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/telegram/telegram.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/)
using the [Telegram Bot API](https://core.telegram.org/bots/api).
Import the `contrib/sranka/telegram` package:
```js
import "contrib/sranka/telegram"
```
## Options
The `contrib/sranka/telegram` package provides the following options:
```js
option telegram.defaultURL = "https://api.telegram.org/bot"
option telegram.defaultParseMode = "MarkdownV2"
option telegram.defaultDisableWebPagePreview = false
option telegram.defaultSilent = true
```
### defaultURL {data-type="string"}
Default Telegram bot URL. Default is `https://api.telegram.org/bot`.
### defaultParseMode {data-type="string"}
Default [Telegram parse mode](https://core.telegram.org/bots/api#formatting-options).
Default is `MarkdownV2`.
### defaultDisableWebPagePreview {data-type="bool"}
Disable Telegram web page preview by default.
Default is `false`.
### defaultSilent {data-type="bool"}
Send silent Telegram notifications by default.
Default is `true`.
## Functions
{{< children type="functions" show="pages" >}}
## Set up a Telegram bot
The **Telegram Bot API** requires a **bot token** and a **channel ID**.
To set up a Telegram bot and obtain the required bot token and channel ID:
1. [Create a new Telegram account](https://telegram.org/) or use an existing account.
2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot).
2. [Create a Telegram bot](https://core.telegram.org/bots#creating-a-new-bot).
Telegram provides a **bot token** for the newly created bot.
3. Use the **Telegram application** to create a new channel.
4. [Add the new bot to the channel](https://stackoverflow.com/questions/33126743/how-do-i-add-my-bot-to-a-channel) as an **Administrator**.
@ -72,3 +56,44 @@ To set up a Telegram bot and obtain the required bot token and channel ID:
```
Find your **channel ID** in the `id` field of the response.
## Options
```js
option telegram.defaultDisableWebPagePreview = false
option telegram.defaultParseMode = "MarkdownV2"
option telegram.defaultSilent = true
option telegram.defaultURL = "https://api.telegram.org/bot"
```
### defaultDisableWebPagePreview
`defaultDisableWebPagePreview` - Use Telegram web page preview by default. Default is `false`.
### defaultParseMode
`defaultParseMode` is the default [Telegram parse mode](https://core.telegram.org/bots/api#formatting-options). Default is `MarkdownV2`.
### defaultSilent
`defaultSilent` - Send silent Telegram notifications by default. Default is `true`.
### defaultURL
`defaultURL` is the default Telegram bot URL. Default is `https://api.telegram.org/bot`.
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,77 +1,108 @@
---
title: telegram.endpoint() function
description: >
The `telegram.endpoint()` function sends a message to a Telegram channel
using data from table rows.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/telegram/endpoint/
`telegram.endpoint()` sends a message to a Telegram channel using data from table rows.
menu:
flux_0_x_ref:
name: telegram.endpoint
parent: telegram
weight: 201
introduced: 0.70.0
flux/v0.x/tags: [notification endpoints]
parent: contrib/sranka/telegram
identifier: contrib/sranka/telegram/endpoint
weight: 301
---
The `telegram.endpoint()` function sends a message to a Telegram channel
using data from table rows.
<!------------------------------------------------------------------------------
```js
import "contrib/sranka/telegram"
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
telegram.endpoint(
url: "https://api.telegram.org/bot",
token: "S3crEtTel3gRamT0k3n",
parseMode: "MarkdownV2",
disableWebPagePreview: false,
)
```
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
{{% note %}}
For information about retrieving your Telegram **bot token** and **channel ID**,
see [Set up a Telegram bot](/v2.0/reference/flux/stdlib/contrib/telegram/#set-up-a-telegram-bot).
{{% /note %}}
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/telegram/telegram.flux#L174-L197
## Parameters
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
### url {data-type="string"}
URL of the Telegram bot endpoint.
Default is `https://api.telegram.org/bot`.
------------------------------------------------------------------------------->
### token {data-type="string"}
({{< req >}})
Telegram bot token.
### parseMode {data-type="string"}
[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text.
Default is `"MarkdownV2"`.
### disableWebPagePreview {data-type="bool"}
Disable preview of web links in the sent message.
Default is `false`.
`telegram.endpoint()` sends a message to a Telegram channel using data from table rows.
## Usage
`telegram.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
### `mapFn`
A function that builds the object used to generate the POST request. Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
`mapFn` accepts a table row (`r`) and returns an object that must include the following fields:
- `channel`
- `text`
- `silent`
_For more information, see [`telegram.message()` parameters](/v2.0/reference/flux/stdlib/contrib/telegram/message/#parameters)._
For more information, see `telegram.message()` parameters.
The returned factory function accepts a `mapFn` parameter.
The `mapFn` must return an record with the following properties:
- `channel`
- `text`
- `silent`
See `telegram.message` parameters for more information.
##### Function type signature
```js
(
token: string,
?disableWebPagePreview: A,
?parseMode: B,
?url: string,
) => (
mapFn: (r: C) => {D with text: G, silent: F, channel: E},
) => (<-tables: stream[C]) => stream[{C with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url
URL of the Telegram bot endpoint. Default is `https://api.telegram.org/bot`.
### token
({{< req >}})
Telegram bot token.
### parseMode
[Parse mode](https://core.telegram.org/bots/api#formatting-options)
of the message text.
Default is `MarkdownV2`.
### disableWebPagePreview
Disable preview of web links in the sent message.
Default is false.
## Examples
##### Send critical statuses to a Telegram channel
### Send critical statuses to a Telegram channel
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/telegram"
@ -87,3 +118,4 @@ crit_statuses =
crit_statuses
|> endpoint(mapFn: (r) => ({channel: "-12345", text: "Disk usage is **${r.status}**.", silent: true}))()
```

View File

@ -1,73 +1,107 @@
---
title: telegram.message() function
description: >
The `telegram.message()` function sends a single message to a Telegram channel using
the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage).
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/telegram/message/
- /influxdb/cloud/reference/flux/stdlib/contrib/telegram/message/
`telegram.message()` sends a single message to a Telegram channel
using the [`sendMessage`](https://core.telegram.org/bots/api#sendmessage) method of the Telegram Bot API.
menu:
flux_0_x_ref:
name: telegram.message
parent: telegram
weight: 201
introduced: 0.70.0
parent: contrib/sranka/telegram
identifier: contrib/sranka/telegram/message
weight: 301
flux/v0.x/tags: [single notification]
---
The `telegram.message()` function sends a single message to a Telegram channel using
the [`sendMessage` method of the Telegram Bot API](https://core.telegram.org/bots/api#sendmessage).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/telegram/telegram.flux#L88-L109
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`telegram.message()` sends a single message to a Telegram channel
using the [`sendMessage`](https://core.telegram.org/bots/api#sendmessage) method of the Telegram Bot API.
##### Function type signature
```js
import "contrib/sranka/telegram"
telegram.message(
url: "https://api.telegram.org/bot",
token: "S3crEtTel3gRamT0k3n",
channel: "-12345",
text: "Example message text",
parseMode: "MarkdownV2",
disableWebPagePreview: false,
silent: true,
)
(
channel: A,
text: B,
token: string,
?disableWebPagePreview: C,
?parseMode: D,
?silent: E,
?url: string,
) => int
```
{{% note %}}
For information about retrieving your Telegram **bot token** and **channel ID**,
see [Set up a Telegram bot](/v2.0/reference/flux/stdlib/contrib/telegram/#set-up-a-telegram-bot).
{{% /note %}}
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
URL of the Telegram bot endpoint.
Default is `https://api.telegram.org/bot`.
### url
### token {data-type="string"}
URL of the Telegram bot endpoint. Default is `https://api.telegram.org/bot`.
### token
({{< req >}})
Telegram bot token.
### channel {data-type="string"}
### channel
({{< req >}})
Telegram channel ID.
### text {data-type="string"}
### text
({{< req >}})
Message text.
### parseMode {data-type="string"}
[Parse mode](https://core.telegram.org/bots/api#formatting-options) of the message text.
Default is `"MarkdownV2"`.
### disableWebPagePreview {data-type="bool"}
### parseMode
[Parse mode](https://core.telegram.org/bots/api#formatting-options)
of the message text.
Default is `MarkdownV2`.
### disableWebPagePreview
Disable preview of web links in the sent message.
Default is `false`.
### silent {data-type="bool"}
### silent
Send message [silently](https://telegram.org/blog/channels-2-0#silent-messages).
Default is `true`.
## Examples
##### Send the last reported status to Telegram
### Send the last reported status to Telegram
```js
import "influxdata/influxdb/secrets"
import "contrib/sranka/telegram"
@ -83,3 +117,4 @@ lastReported =
telegram.message(token: token, channel: "-12345", text: "Disk usage is **${lastReported.status}**.")
```

View File

@ -1,28 +1,46 @@
---
title: Flux webexteams package
list_title: webexteams package
title: webexteams package
description: >
The Flux `webexteams` package provides functions that send messages to
[Webex Teams](https://www.webex.com/team-collaboration.html).
The `webexteams` package provides functions that send messages
to [Webex Teams](https://www.webex.com/team-collaboration.html).
menu:
flux_0_x_ref:
name: webexteams
parent: sranka
weight: 202
name: webexteams
parent: contrib/sranka
identifier: contrib/sranka/webexteams
weight: 31
cascade:
introduced: 0.125.0
influxdb/v2.0/tags: [functions, webex, package]
---
The Flux `webexteams` package provides functions that send messages to
[Webex Teams](https://www.webex.com/team-collaboration.html).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/webexteams/webexteams.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `webexteams` package provides functions that send messages
to [Webex Teams](https://www.webex.com/team-collaboration.html).
Import the `contrib/sranka/webexteams` package:
```js
import "contrib/sranka/webexteams"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,78 +1,60 @@
---
title: webexteams.endpoint() function
description: >
The `webexteams.endpoint()` function sends a single message to Webex using the
[Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
`webexteams.endpoint()` returns a function that sends a message that includes data from input rows to a Webex room.
menu:
flux_0_x_ref:
name: webexteams.endpoint
parent: webexteams
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/endpoint/
- /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/endpoint/
flux/v0.x/tags: [notification endpoints]
parent: contrib/sranka/webexteams
identifier: contrib/sranka/webexteams/endpoint
weight: 301
---
The `webexteams.endpoint()` function returns a function that sends a message that
includes data from input rows to a Webex room.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/webexteams/webexteams.flux#L112-L133
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`webexteams.endpoint()` returns a function that sends a message that includes data from input rows to a Webex room.
##### Function type signature
```js
import "contrib/sranka/webexteams"
webexteams.endpoint(
url: "https://webexapis.com",
token: "token",
)
(
token: string,
?url: string,
) => (
mapFn: (r: A) => {B with text: E, roomId: D, markdown: C},
) => (<-tables: stream[A]) => stream[{A with _sent: string}]
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### url {data-type="string"}
Base URL of Webex API endpoint _(without a trailing slash)_.
### url
Base URL of Webex API endpoint (without a trailing slash).
Default is `https://webexapis.com`.
### token {data-type="string"}
### token
({{< req >}})
[Webex API access token](https://developer.webex.com/docs/api/getting-started).
## Usage
`webexteams.endpoint` is a factory function that outputs another function.
The output function requires a `mapFn` parameter.
### mapFn {data-type="function"}
A function that builds the object used to generate the POST request.
Requires an `r` parameter.
`mapFn` accepts a table row (`r`) and returns an object that must include the
following fields:
- `roomId`
- `text`
- `markdown`
_For more information, see [`webexteams.message()` parameters](/flux/v0.x/stdlib/contrib/sranka/webexteams/message/#parameters)._
## Examples
##### Send the last reported status to Webex Teams
```js
import "contrib/sranka/webexteams"
import "influxdata/influxdb/secrets"
token = secrets.get(key: "WEBEX_API_KEY")
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> tableFind(fn: (key) => true)
|> webexteams.endpoint(token: token)(
mapFn: (r) =>
({
roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0",
text: "",
markdown: "Disk usage is **${r.status}**.",
}),
)
```

View File

@ -1,58 +1,90 @@
---
title: webexteams.message() function
description: >
The `webexteams.message()` function sends a single message to Webex using the
[Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
`webexteams.message()` sends a single message to Webex
using the [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
menu:
flux_0_x_ref:
name: webexteams.message
parent: webexteams
weight: 202
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/message/
- /influxdb/cloud/reference/flux/stdlib/contrib/webexteams/message/
parent: contrib/sranka/webexteams
identifier: contrib/sranka/webexteams/message
weight: 301
flux/v0.x/tags: [single notification]
---
The `webexteams.message()` function sends a single message to Webex using the
[Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/sranka/webexteams/webexteams.flux#L49-L63
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`webexteams.message()` sends a single message to Webex
using the [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
##### Function type signature
```js
import "contrib/sranka/webexteams"
webexteams.message(,
url: "https://webexapis.com"
token: "My5uP3rs3cRe7T0k3n",
roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0",
text: "Example plain text message",
markdown: "Example [markdown message](https://developer.webex.com/docs/api/basics).",
)
(
markdown: A,
roomId: B,
text: C,
token: string,
?url: string,
) => int
```
## Parameters
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
### url {data-type="string"}
Base URL of Webex API endpoint _(without a trailing slash)_.
## Parameters
### url
Base URL of Webex API endpoint (without a trailing slash).
Default is `https://webexapis.com`.
### token {data-type="string"}
### token
({{< req >}})
[Webex API access token](https://developer.webex.com/docs/api/getting-started).
### roomId {data-type="string"}
### roomId
({{< req >}})
Room ID to send the message to.
### text {data-type="string"}
### text
({{< req >}})
Plain text message.
### markdown {data-type="string"}
### markdown
({{< req >}})
[Markdown formatted message](https://developer.webex.com/docs/api/basics#formatting-messages).
## Examples
##### Send the last reported status to Webex Teams
### Send the last reported status to Webex Teams
```js
import "contrib/sranka/webexteams"
import "influxdata/influxdb/secrets"
@ -73,3 +105,4 @@ webexteams.message(
markdown: "Disk usage is **${lastReported.status}**.",
)
```

View File

@ -1,27 +1,36 @@
---
title: Packages contributed by tomhollingworth
list_title: tomhollingworth package
title: tomhollingworth package
description: >
The `tomhollingworth` package contains functions and packages contributed by
[@tomhollingworth](https://github.com/tomhollingworth).
The `tomhollingworth` package contains packages and functions contributed by [@tomhollingworth](https://github.com/tomhollingworth).
menu:
flux_0_x_ref:
name: tomhollingworth
name: tomhollingworth
parent: contrib
weight: 101
cascade:
introduced: 0.91.0
append:
block: note
content: |
#### Package author and maintainer
**Github:** [@tomhollingworth](https://github.com/tomhollingworth)
**InfluxDB Slack:** [@Tom Hollingworth](https://influxdata.com/slack)
identifier: contrib/tomhollingworth
weight: 21
---
The `tomhollingworth` package contains functions and packages contributed by
[@tomhollingworth](https://github.com/tomhollingworth).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/tomhollingworth/tomhollingworth.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `tomhollingworth` package contains packages and functions contributed by [@tomhollingworth](https://github.com/tomhollingworth).
## Packages
{{< children >}}
{{< children show="sections" >}}

View File

@ -1,26 +1,44 @@
---
title: Flux Events package
list_title: Events package
title: events package
description: >
The Flux Events package provides tools for analyzing event-based data.
Import the `contrib/tomhollingworth/events` package.
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/events/
- /influxdb/cloud/reference/flux/stdlib/contrib/events/
The `events` package provides tools for analyzing event-based data.
menu:
flux_0_x_ref:
name: events
parent: tomhollingworth
identifier: tomhollingworth-events
weight: 201
flux/v0.x/tags: [functions, events, package]
name: events
parent: contrib/tomhollingworth
identifier: contrib/tomhollingworth/events
weight: 31
cascade:
introduced: 0.91.0
---
The Flux Events package provides tools for analyzing event-based data.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/tomhollingworth/events/events.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `events` package provides tools for analyzing event-based data.
Import the `contrib/tomhollingworth/events` package:
```js
import "contrib/tomhollingworth/events"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,150 +1,190 @@
---
title: events.duration() function
description: >
The `events.duration()` function calculates the duration of events.
The function determines the time between a record and the subsequent record and
associates the duration with the first record (start of the event).
aliases:
- /influxdb/v2.0/reference/flux/stdlib/contrib/events/duration/
- /influxdb/cloud/reference/flux/stdlib/contrib/events/duration/
`events.duration()` calculates the duration of events.
menu:
flux_0_x_ref:
name: events.duration
parent: tomhollingworth-events
parent: contrib/tomhollingworth/events
identifier: contrib/tomhollingworth/events/duration
weight: 301
flux/v0.x/tags: [functions, events, package]
related:
- /flux/v0.x/stdlib/universe/elapsed/
- /flux/v0.x/stdlib/universe/stateduration/
flux/v0.x/tags: [transformations, events]
---
The `events.duration()` function calculates the duration of events.
The function determines the time between a record and the subsequent record and
associates the duration with the first record (start of the event).
To calculate the duration of the last event, the function compares the timestamp
of the final record to the timestamp in the [`stopColumn`](#stopcolumn) or the
specified [`stop`](#stop) time.
<!------------------------------------------------------------------------------
```js
import "contrib/tomhollingworth/events"
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
events.duration(
unit: 1ns,
columnName: "duration",
timeColumn: "_time",
stopColumn: "_stop",
stop: 2020-01-01T00:00:00Z,
)
```
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
{{% note %}}
#### Similar functions
`events.duration()` is similar to `elapsed()` and `stateDuration()`, but differs
in important ways:
https://github.com/influxdata/flux/blob/master/stdlib/contrib/tomhollingworth/events/duration.flux#L99-L109
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`events.duration()` calculates the duration of events.
The function determines the time between a record and the subsequent record
and associates the duration with the first record (start of the event).
To calculate the duration of the last event,
the function compares the timestamp of the final record
to the timestamp in the `stopColumn` or the specified stop time.
### Similar functions
`events.duration()` is similar to `elapsed()` and `stateDuration()`, but differs in important ways:
- `elapsed()` drops the first record. `events.duration()` does not.
- `stateDuration()` calculates the total time spent in a state (determined by a
[predicate function](/flux/v0.x/get-started/syntax-basics/#predicate-functions)).
- `stateDuration()` calculates the total time spent in a state (determined by a predicate function).
`events.duration()` returns the duration between all records and their subsequent records.
For examples, see [below](#compared-to-similar-functions).
{{% /note %}}
See the example [below](#compared-to-similar-functions).
##### Function type signature
```js
(
<-tables: stream[A],
?columnName: string,
?stop: time,
?stopColumn: string,
?timeColumn: string,
?unit: duration,
) => stream[B] where A: Record, B: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### unit {data-type="duration"}
### unit
Duration unit of the calculated state duration.
Default is `1ns`
### columnName {data-type="string"}
### columnName
Name of the result column.
Default is `"duration"`.
### timeColumn {data-type="string"}
### timeColumn
Name of the time column.
Default is `"_time"`.
### stopColumn {data-type="string"}
### stopColumn
Name of the stop column.
Default is `"_stop"`.
### stop {data-type="time"}
The latest time to use when calculating results.
If provided, `stop` overrides the time value in the [`stopColumn`](#stopcolumn).
### tables {data-type="stream of tables"}
Input data.
Default is piped-forward data ([`<-`](/flux/v0.x/spec/expressions/#pipe-expressions)).
### stop
The latest time to use when calculating results.
If provided, `stop` overrides the time value in the `stopColumn`.
### tables
Input data. Default is piped-forward data (`<-`).
## Examples
##### Calculate the duration of states
- [Calculate the duration of states](#calculate-the-duration-of-states)
- [Compared to similar functions](#compared-to-similar-functions)
### Calculate the duration of states
```js
import "array"
import "contrib/tomhollingworth/events"
data
|> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z)
```
{{< flex >}}
{{% flex-content %}}
##### Input
| _time | state |
|:----- | -----:|
| 2020-01-01T00:00:00Z | ok |
| 2020-01-01T00:12:34Z | warn |
| 2020-01-01T00:25:01Z | ok |
| 2020-01-01T16:07:55Z | crit |
| 2020-01-01T16:54:21Z | warn |
| 2020-01-01T18:20:45Z | ok |
{{% /flex-content %}}
{{% flex-content %}}
##### Output
| _time | state | duration |
|:----- |:-----:| --------:|
| 2020-01-01T00:00:00Z | ok | 12 |
| 2020-01-01T00:12:34Z | warn | 12 |
| 2020-01-01T00:25:01Z | ok | 942 |
| 2020-01-01T16:07:55Z | crit | 46 |
| 2020-01-01T16:54:21Z | warn | 86 |
| 2020-01-01T18:20:45Z | ok | 339 |
{{% /flex-content %}}
{{< /flex >}}
{{< expand-wrapper >}}
{{% expand "View example input and ouput" %}}
## Compared to similar functions
The example below includes output values of `events.duration()`, `elapsed()`, and
`stateDuration()` related to the `_time` and `state` values of input data.
#### Input data
| _time | state |
| -------------------- | ------ |
| 2020-01-01T00:00:00Z | ok |
| 2020-01-01T00:12:34Z | warn |
| 2020-01-01T00:25:01Z | ok |
| 2020-01-01T16:07:55Z | crit |
| 2020-01-01T16:54:21Z | warn |
| 2020-01-01T18:20:45Z | ok |
#### Output data
| _time | state | duration |
| -------------------- | ------ | --------- |
| 2020-01-01T00:00:00Z | ok | 12 |
| 2020-01-01T00:12:34Z | warn | 12 |
| 2020-01-01T00:25:01Z | ok | 942 |
| 2020-01-01T16:07:55Z | crit | 46 |
| 2020-01-01T16:54:21Z | warn | 86 |
| 2020-01-01T18:20:45Z | ok | 339 |
{{% /expand %}}
{{< /expand-wrapper >}}
### Compared to similar functions
The example below includes output values of
`events.duration()`, `elapsed()`, and `stateDuration()`
related to the `_time` and `state` values of input data.
{{< flex >}}
{{% flex-content %}}
##### Input
| _time | state |
|:----- | -----:|
| 2020-01-01T00:00:00Z | ok |
| 2020-01-01T00:12:34Z | warn |
| 2020-01-01T00:25:01Z | ok |
| 2020-01-01T16:07:55Z | crit |
| 2020-01-01T16:54:21Z | warn |
| 2020-01-01T18:20:45Z | ok |
{{% /flex-content %}}
{{% flex-content %}}
##### Functions
```js
data |> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z)
import "array"
import "contrib/tomhollingworth/events"
data |> elapsed(unit: 1m)
data |> stateDuration(unit: 1m, fn: (r) => true)
union(
tables: [
data
|> events.duration(unit: 1m, stop: 2020-01-02T00:00:00Z)
|> map(fn: (r) => ({_time: r._time, state: r.state, function: "events.Duration()", value: r.duration})),
data
|> elapsed(unit: 1m)
|> map(fn: (r) => ({_time: r._time, state: r.state, function: "elapsed()", value: r.elapsed})),
data
|> stateDuration(unit: 1m, fn: (r) => true)
|> map(fn: (r) => ({_time: r._time, state: r.state, function: "stateDuration()", value: r.stateDuration})),
],
)
|> pivot(rowKey: ["_time", "state"], columnKey: ["function"], valueColumn: "value")
```
{{% /flex-content %}}
{{< /flex >}}
##### Output values
| _time | state | events.duration() | elapsed() | stateDuration() |
|:----- |:-----:| -----------------:| ---------: | ---------------:|
| 2020-01-01T00:00:00Z | ok | 12 | <span style="opacity:.2">N/A</span> | 0 |
| 2020-01-01T00:12:34Z | warn | 12 | 12 | 12 |
| 2020-01-01T00:25:01Z | ok | 942 | 12 | 25 |
| 2020-01-01T16:07:55Z | crit | 46 | 942 | 967 |
| 2020-01-01T16:54:21Z | warn | 86 | 46 | 1014 |
| 2020-01-01T18:20:45Z | ok | 339 | 86 | 1100 |
{{< expand-wrapper >}}
{{% expand "View example output" %}}
#### Output data
| _time | state | events.Duration() | elapsed() | stateDuration() |
| -------------------- | ------ | ------------------ | ---------- | ---------------- |
| 2020-01-01T00:00:00Z | ok | 12 | | 0 |
| 2020-01-01T00:12:34Z | warn | 12 | 12 | 12 |
| 2020-01-01T00:25:01Z | ok | 942 | 12 | 25 |
| 2020-01-01T16:07:55Z | crit | 46 | 942 | 967 |
| 2020-01-01T16:54:21Z | warn | 86 | 46 | 1014 |
| 2020-01-01T18:20:45Z | ok | 339 | 86 | 1100 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,28 +1,44 @@
---
title: Flux csv package
list_title: csv package
title: csv package
description: >
The Flux `csv` package provides functions for working with data in annotated CSV format.
Import the `csv` package.
aliases:
- /influxdb/v2.0/reference/flux/functions/csv/
- /influxdb/v2.0/reference/flux/stdlib/csv/
- /influxdb/cloud/reference/flux/stdlib/csv/
The `csv` package provides tools for working with data in annotated CSV format.
menu:
flux_0_x_ref:
name: csv
parent: Standard library
name: csv
parent: stdlib
identifier: csv
weight: 11
flux/v0.x/tags: [functions, csv, package]
introduced: 0.14.0
cascade:
flux/v0.x/tags: [csv]
introduced: 0.14.0
---
The Flux `csv` package provides functions for working with data in
[annotated CSV format](https://github.com/influxdata/flux/blob/master/docs/SPEC.md#csv).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/csv/csv.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `csv` package provides tools for working with data in annotated CSV format.
Import the `csv` package:
```js
import "csv"
```
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,115 +1,144 @@
---
title: csv.from() function
description: The `csv.from()` function retrieves data from a CSV data source.
aliases:
- /influxdb/v2.0/reference/flux/functions/inputs/fromcsv
- /influxdb/v2.0/reference/flux/functions/built-in/inputs/fromcsv
- /influxdb/v2.0/reference/flux/functions/csv/from/
- /influxdb/v2.0/reference/flux/stdlib/csv/from/
- /influxdb/cloud/reference/flux/stdlib/csv/from/
description: >
`csv.from()` retrieves data from a comma separated value (CSV) data source and
returns a stream of tables.
menu:
flux_0_x_ref:
name: csv.from
parent: csv
weight: 202
flux/v0.x/tags: [inputs]
introduced: 0.14.0
identifier: csv/from
weight: 101
flux/v0.x/tags: [csv, inputs]
---
The `csv.from()` function retrieves data from a comma-separated value (CSV) data source.
It returns a stream of tables.
Each unique series is contained within its own table.
Each record in the table represents a single point in the series.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/csv/csv.flux#L94-L94
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`csv.from()` retrieves data from a comma separated value (CSV) data source and
returns a stream of tables.
##### Function type signature
```js
import "csv"
csv.from(
csv: csvData,
mode: "annotations",
)
// OR
csv.from(
file: "/path/to/data-file.csv",
mode: "annotations",
)
(?csv: string, ?file: string, ?mode: string) => stream[A] where A: Record
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### csv {data-type="string"}
### csv
CSV data.
Supports [annotated CSV](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/) or raw CSV.
Use [`mode`](#mode) to specify the parsing mode.
{{% note %}}
Annotated CSV data must include all [annotation rows](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/#annotations).
{{% /note %}}
Supports anonotated CSV or raw CSV. Use `mode` to specify the parsing mode.
### file
File path of the CSV file to query.
### file {data-type="string"}
The file path of the CSV file to query.
The path can be absolute or relative.
If relative, it is relative to the working directory of the `fluxd` process.
_The CSV file must exist in the same file system running the `fluxd` process._
The CSV file must exist in the same file system running the `fluxd` process.
{{% warn %}}
**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ support the `file` parameter.
Neither allow access to the underlying filesystem.
However, the [Flux REPL](/{{< latest "influxdb" >}}/tools/repl/) does support the `file` parameter.
{{% /warn %}}
### mode
### mode {data-type="string"}
CSV parsing mode.
Default is `annotations`.
is the CSV parsing mode. Default is `annotations`.
**Available annotation modes**
- **annotations**: Use CSV notations to determine column data types.
- **raw**: Parse all columns as strings and use the first row as the
header row and all subsequent rows as data.
##### Available modes
- **annotations:** Use CSV annotations to determine column data types.
- **raw:** Parse all columns as strings and use the first row as the
[header row](/{{< latest "influxdb" >}}/reference/syntax/annotated-csv/#rows) and all
subsequent rows as data.
## Examples
- [Query annotated CSV data from a file](#query-annotated-csv-data-from-a-file)
- [Query raw CSV data from a file](#query-raw-csv-data-from-a-file)
- [Query anotated CSV data from file](#query-anotated-csv-data-from-file)
- [Query raw data from CSV file](#query-raw-data-from-csv-file)
- [Query an annotated CSV string](#query-an-annotated-csv-string)
- [Query a raw CSV string](#query-a-raw-csv-string)
##### Query annotated CSV data from a file
### Query anotated CSV data from file
```js
import "csv"
csv.from(file: "/path/to/data-file.csv")
csv.from(file: "path/to/data-file.csv")
```
##### Query raw CSV data from a file
### Query raw data from CSV file
```js
import "csv"
csv.from(file: "/path/to/data-file.csv", mode: "raw")
```
##### Query an annotated CSV string
### Query an annotated CSV string
```js
import "csv"
csvData =
"
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double
#group,false,false,false,false,false,false,false,false
#group,false,false,false,false,false,true,true,false
#default,,,,,,,,
,result,table,_start,_stop,_time,region,host,_value
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:00Z,east,A,65.15
,mean,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
,mean,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:20Z,east,B,18.67
,mean,2,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
,mean,2,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:51:40Z,east,C,82.16
"
csv.from(csv: csvData)
```
##### Query a raw CSV string
{{< expand-wrapper >}}
{{% expand "View example output" %}}
#### Output data
| _start | _stop | _time | *region | *host | _value |
| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:00Z | east | A | 15.43 |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:00Z | east | A | 65.15 |
| _start | _stop | _time | *region | *host | _value |
| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:20Z | east | B | 59.25 |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:20Z | east | B | 18.67 |
| _start | _stop | _time | *region | *host | _value |
| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:40Z | east | C | 52.62 |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:51:40Z | east | C | 82.16 |
{{% /expand %}}
{{< /expand-wrapper >}}
### Query a raw CSV string
```js
import "csv"
@ -125,8 +154,15 @@ csv.from(csv: csvData, mode: "raw")
```
{{< expand-wrapper >}}
{{% expand "Function updates" %}}
#### v0.109.0
- Add `mode` parameter to support querying raw CSV data.
{{% expand "View example output" %}}
#### Output data
| _start | _stop | _time | region | host | _value |
| -------------------- | -------------------- | -------------------- | ------- | ----- | ------- |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:00Z | east | A | 15.43 |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:20Z | east | B | 59.25 |
| 2018-05-08T20:50:00Z | 2018-05-08T20:51:00Z | 2018-05-08T20:50:40Z | east | C | 52.62 |
{{% /expand %}}
{{< /expand-wrapper >}}

View File

@ -1,64 +1,86 @@
---
title: Flux date package
list_title: date package
title: date package
description: >
The Flux `date` package provides date and time constants and functions.
Import the `date` package.
aliases:
- /influxdb/v2.0/reference/flux/language/built-ins/time-constants/
- /influxdb/v2.0/reference/flux/functions/date/
- /influxdb/v2.0/reference/flux/stdlib/date/
- /influxdb/cloud/reference/flux/stdlib/date/
The `date` package provides date and time constants and functions.
menu:
flux_0_x_ref:
name: date
parent: Standard library
name: date
parent: stdlib
identifier: date
weight: 11
cascade:
flux/v0.x/tags: [date/time]
introduced: 0.37.0
introduced: 0.37.0
---
The Flux `date` package provides date and time constants and functions.
Import the `date` package.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
The `date` package provides date and time constants and functions.
Import the `date` package:
```js
import "date"
```
## Date and time constants
That `date` package includes the following date and time constants.
### Days of the week
Days of the week are represented as integers in the range `[0-6]`.
## Constants
```js
date.Sunday = 0
date.Monday = 1
date.Tuesday = 2
date.Wednesday = 3
date.Thursday = 4
date.Friday = 5
date.Saturday = 6
```
### Months of the year
Months are represented as integers in the range `[1-12]`.
```js
date.January = 1
date.February = 2
date.March = 3
date.April = 4
date.May = 5
date.June = 6
date.July = 7
date.August = 8
date.April = 4
date.August = 8
date.December = 12
date.February = 2
date.Friday = 5
date.January = 1
date.July = 7
date.June = 6
date.March = 3
date.May = 5
date.Monday = 1
date.November = 11
date.October = 10
date.Saturday = 6
date.September = 9
date.October = 10
date.November = 11
date.December = 12
date.Sunday = 0
date.Thursday = 4
date.Tuesday = 2
date.Wednesday = 3
```
## Date and time functions
- **date.April** is a constant that represents the month of April.
- **date.August** is a constant that represents the month of August.
- **date.December** is a constant that represents the month of December.
- **date.February** is a constant that represents the month of February.
- **date.Friday** is a constant that represents Friday as a day of the week.
- **date.January** is a constant that represents the month of January.
- **date.July** is a constant that represents the month of July.
- **date.June** is a constant that represents the month of June.
- **date.March** is a constant that represents the month of March.
- **date.May** is a constant that represents the month of May.
- **date.Monday** is a constant that represents Monday as a day of the week.
- **date.November** is a constant that represents the month of November.
- **date.October** is a constant that represents the month of October.
- **date.Saturday** is a constant that represents Saturday as a day of the week.
- **date.September** is a constant that represents the month of September.
- **date.Sunday** is a constant that represents Sunday as a day of the week
- **date.Thursday** is a constant that represents Thursday as a day of the week.
- **date.Tuesday** is a constant that represents Tuesday as a day of the week.
- **date.Wednesday** is a constant that represents Wednesday as a day of the week.
## Functions
{{< children type="functions" show="pages" >}}

View File

@ -1,56 +1,106 @@
---
title: date.add() function
description: >
`date.add()` adds a duration to a time value and returns the resulting time.
`date.add()` adds a duration to a time value and returns the resulting time value.
menu:
flux_0_x_ref:
name: date.add
parent: date
weight: 302
identifier: date/add
weight: 101
flux/v0.x/tags: [date/time]
aliases:
- /flux/v0.x/stdlib/date/addduration/
related:
- /flux/v0.x/stdlib/date/subduration/
introduced: 0.162.0
---
`date.add()` adds a duration to a time value and returns the resulting time.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L555-L555
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.add()` adds a duration to a time value and returns the resulting time value.
##### Function type signature
```js
import "date"
date.add(d: 12h, to: now())
(d: duration, to: A, ?location: {zone: string, offset: duration}) => time where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### d {data-type="duration"}
### d
({{< req >}})
Duration to add.
### to {data-type="time, duration"}
Time to add the [duration](#d) to.
### to
({{< req >}})
Time to add the duration to.
### location
Location to use for the time value.
Use an absolute time or a relative duration.
Durations are relative to [`now()`](/flux/v0.x/stdlib/universe/now/).
Durations are relative to `now()`.
## Examples
- [Add six hours to a timestamp](#add-six-hours-to-a-timestamp)
- [Add one month to yesterday](#add-one-month-to-yesterday)
- [Add six hours to a relative duration](#add-six-hours-to-a-relative-duration)
### Add six hours to a timestamp
```js
import "date"
date.add(d: 6h, to: 2019-09-16T12:00:00Z)
date.add(d: 6h, to: 2019-09-16T12:00:00Z)// Returns 2019-09-16T18:00:00.000000000Z
// Returns 2019-09-16T18:00:00.000000000Z
```
### Add one month to yesterday
A time may be represented as either an explicit timestamp
or as a relative time from the current `now` time. add can
support either type of value.
```js
import "date"
option now = () => 2021-12-10T16:27:40Z
date.add(d: 1mo, to: -1d)// Returns 2022-01-09T16:27:40Z
```
### Add six hours to a relative duration
```js
import "date"
option now = () => 2022-01-01T12:00:00Z
date.add(d: 6h, to: 3h)
date.add(d: 6h, to: 3h)// Returns 2022-01-01T21:00:00.000000000Z
// Returns 2022-01-01T21:00:00.000000000Z
```

View File

@ -1,56 +1,83 @@
---
title: date.hour() function
description: >
The `date.hour()` function returns the hour of a specified time.
Results range from `[0-23]`.
aliases:
- /influxdb/v2.0/reference/flux/functions/date/hour/
- /influxdb/v2.0/reference/flux/stdlib/date/hour/
- /influxdb/cloud/reference/flux/stdlib/date/hour/
`date.hour()` returns the hour of a specified time. Results range from `[0 - 23]`.
menu:
flux_0_x_ref:
name: date.hour
parent: date
weight: 301
introduced: 0.37.0
identifier: date/hour
weight: 101
---
The `date.hour()` function returns the hour of a specified time.
Results range from `[0-23]`.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L117-L117
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.hour()` returns the hour of a specified time. Results range from `[0 - 23]`.
##### Function type signature
```js
import "date"
date.hour(t: 2019-07-17T12:05:21.012Z)
// Returns 12
(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### t {data-type="time, duration"}
The time to operate on.
### t
({{< req >}})
Time to operate on.
Use an absolute time, relative duration, or integer.
Durations are relative to `now()`.
### location
Location used to determine timezone.
Default is the `location` option.
## Examples
##### Return the hour of a time value
- [Return the hour of a time value](#return-the-hour-of-a-time-value)
- [Return the hour of a relative duration](#return-the-hour-of-a-relative-duration)
### Return the hour of a time value
```js
import "date"
date.hour(t: 2020-02-11T12:21:03.293534940Z)
date.hour(t: 2020-02-11T12:21:03.29353494Z)// Returns 12
// Returns 12
```
##### Return the hour of a relative duration
### Return the hour of a relative duration
```js
import "date"
option now = () => 2020-02-11T12:21:03.293534940Z
option now = () => 2020-02-11T12:21:03.29353494Z
date.hour(t: -8h)
date.hour(t: -8h)// Returns 7
// Returns 4
```

View File

@ -1,56 +1,78 @@
---
title: date.microsecond() function
description: >
The `date.microsecond()` function returns the microsecond of a specified time.
Results range from `[0-999999]`.
aliases:
- /influxdb/v2.0/reference/flux/functions/date/microsecond/
- /influxdb/v2.0/reference/flux/stdlib/date/microsecond/
- /influxdb/cloud/reference/flux/stdlib/date/microsecond/
`date.microsecond()` returns the microseconds for a specified time.
Results range `from [0-999999]`.
menu:
flux_0_x_ref:
name: date.microsecond
parent: date
weight: 301
introduced: 0.37.0
identifier: date/microsecond
weight: 101
---
The `date.microsecond()` function returns the microsecond of a specified time.
Results range from `[0-999999]`.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L462-L462
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.microsecond()` returns the microseconds for a specified time.
Results range `from [0-999999]`.
##### Function type signature
```js
import "date"
date.microsecond(t: 2019-07-17T12:05:21.012934584Z)
// Returns 12934
(t: A) => int where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### t {data-type="time, duration"}
The time to operate on.
### t
({{< req >}})
Time to operate on.
Use an absolute time, relative duration, or integer.
Durations are relative to `now()`.
## Examples
##### Return the microsecond of a time value
- [Return the microsecond of a time value](#return-the-microsecond-of-a-time-value)
- [Return the microsecond of a relative duration](#return-the-microsecond-of-a-relative-duration)
### Return the microsecond of a time value
```js
import "date"
date.microsecond(t: 2020-02-11T12:21:03.293534940Z)
date.microsecond(t: 2020-02-11T12:21:03.29353494Z)// Returns 293534
// Returns 293534
```
##### Return the microsecond of a relative duration
### Return the microsecond of a relative duration
```js
import "date"
option now = () => 2020-02-11T12:21:03.293534940Z
option now = () => 2020-02-11T12:21:03.29353494Z
date.microsecond(t: -1890us)
date.microsecond(t: -1890us)// Returns 322661
// Returns 291644
```

View File

@ -1,56 +1,78 @@
---
title: date.millisecond() function
description: >
The `date.millisecond()` function returns the millisecond of a specified time.
Results range from `[0-999999]`.
aliases:
- /influxdb/v2.0/reference/flux/functions/date/millisecond/
- /influxdb/v2.0/reference/flux/stdlib/date/millisecond/
- /influxdb/cloud/reference/flux/stdlib/date/millisecond/
`date.millisecond()` returns the milliseconds for a specified time.
Results range from `[0-999]`.
menu:
flux_0_x_ref:
name: date.millisecond
parent: date
weight: 301
introduced: 0.37.0
identifier: date/millisecond
weight: 101
---
The `date.millisecond()` function returns the millisecond of a specified time.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L428-L428
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.millisecond()` returns the milliseconds for a specified time.
Results range from `[0-999]`.
##### Function type signature
```js
import "date"
date.millisecond(t: 2019-07-17T12:05:21.012934584Z)
// Returns 12
(t: A) => int where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### t {data-type="time, duration"}
The time to operate on.
### t
({{< req >}})
Time to operate on.
Use an absolute time, relative duration, or integer.
Durations are relative to `now()`.
## Examples
##### Return the millisecond of a time value
- [Return the millisecond of the time value](#return-the-millisecond-of-the-time-value)
- [Return the millisecond of a relative duration](#return-the-millisecond-of-a-relative-duration)
### Return the millisecond of the time value
```js
import "date"
date.millisecond(t: 2020-02-11T12:21:03.293534940Z)
date.millisecond(t: 2020-02-11T12:21:03.29353494Z)// Returns 293
// Returns 293
```
##### Return the millisecond of a relative duration
### Return the millisecond of a relative duration
```js
import "date"
option now = () => 2020-02-11T12:21:03.293534940Z
option now = () => 2020-02-11T12:21:03.29353494Z
date.millisecond(t: -150ms)
date.millisecond(t: -150ms)// Returns 127
// Returns 143
```

View File

@ -1,56 +1,83 @@
---
title: date.minute() function
description: >
The `date.minute()` function returns the minute of a specified time.
Results range from `[0-59]`.
aliases:
- /influxdb/v2.0/reference/flux/functions/date/minute/
- /influxdb/v2.0/reference/flux/stdlib/date/minute/
- /influxdb/cloud/reference/flux/stdlib/date/minute/
`date.minute()` returns the minute of a specified time. Results range from `[0 - 59]`.
menu:
flux_0_x_ref:
name: date.minute
parent: date
weight: 301
introduced: 0.37.0
identifier: date/minute
weight: 101
---
The `date.minute()` function returns the minute of a specified time.
Results range from `[0-59]`.
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L78-L78
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.minute()` returns the minute of a specified time. Results range from `[0 - 59]`.
##### Function type signature
```js
import "date"
date.minute(t: 2019-07-17T12:05:21.012Z)
// Returns 5
(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### t {data-type="time, duration"}
The time to operate on.
### t
({{< req >}})
Time to operate on.
Use an absolute time, relative duration, or integer.
Durations are relative to `now()`.
### location
Location used to determine timezone.
Default is the `location` option.
## Examples
##### Return the minute of a time value
- [Return the minute of a time value](#return-the-minute-of-a-time-value)
- [Return the minute of a relative duration](#return-the-minute-of-a-relative-duration)
### Return the minute of a time value
```js
import "date"
date.minute(t: 2020-02-11T12:21:03.293534940Z)
date.minute(t: 2020-02-11T12:21:03.29353494Z)// Returns 21
// Returns 21
```
##### Return the minute of a relative duration
### Return the minute of a relative duration
```js
import "date"
option now = () => 2020-02-11T12:21:03.293534940Z
option now = () => 2020-02-11T12:21:03.29353494Z
date.minute(t: -45m)
date.minute(t: -45m)// Returns 6
// Returns 36
```

View File

@ -1,57 +1,83 @@
---
title: date.month() function
description: >
The `date.month()` function returns the month of a specified time.
Results range from `[1-12]`.
aliases:
- /influxdb/v2.0/reference/flux/functions/date/month/
- /influxdb/v2.0/reference/flux/stdlib/date/month/
- /influxdb/cloud/reference/flux/stdlib/date/month/
`date.month()` returns the month of a specified time. Results range from `[1 - 12]`.
menu:
flux_0_x_ref:
name: date.month
parent: date
weight: 301
introduced: 0.37.0
identifier: date/month
weight: 101
---
The `date.month()` function returns the month of a specified time.
Results range from `[1-12]` and correspond to `date` package
[month constants](/flux/v0.x/stdlib/date/#months-of-the-year).
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the function comments above the
function definition in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/date/date.flux#L276-L276
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`date.month()` returns the month of a specified time. Results range from `[1 - 12]`.
##### Function type signature
```js
import "date"
date.month(t: 2019-07-17T12:05:21.012Z)
// Returns 7
(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable
```
{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}}
## Parameters
### t {data-type="time, duration"}
The time to operate on.
### t
({{< req >}})
Time to operate on.
Use an absolute time, relative duration, or integer.
Durations are relative to `now()`.
### location
Location used to determine timezone.
Default is the `location` option.
## Examples
##### Return the month of a time value
- [Return the month of a time value](#return-the-month-of-a-time-value)
- [Return the month of a relative duration](#return-the-month-of-a-relative-duration)
### Return the month of a time value
```js
import "date"
date.month(t: 2020-02-11T12:21:03.293534940Z)
date.month(t: 2020-02-11T12:21:03.29353494Z)// Returns 2
// Returns 2
```
##### Return the month of a relative duration
### Return the month of a relative duration
```js
import "date"
option now = () => 2020-02-11T12:21:03.293534940Z
option now = () => 2020-02-11T12:21:03.29353494Z
date.month(t: -3mo)
date.month(t: -3mo)// Returns 8
// Returns 11
```

Some files were not shown because too many files have changed in this diff Show More