Various Flux documentation fixes (#1867)
* closes influxdata/DAR#145 * added info about pivot dropping columns not in the group key, resolves #1836 * added column param to last function, closes #1823, closes influxdata/flux#3316 * closes #1707 * closes #1672 * closes #1650pull/1873/head
parent
c0bcee3342
commit
86fe195c4d
|
@ -15,91 +15,4 @@ related:
|
|||
- /{{< latest "influxdb" "v1" >}}/query_language/functions/#percentile, InfluxQL – PERCENTILE()
|
||||
---
|
||||
|
||||
The `quantile()` function returns records from an input table with `_value`s that fall within
|
||||
a specified quantile or it returns the record with the `_value` that represents the specified quantile.
|
||||
Which it returns depends on the [method](#method) used.
|
||||
`quantile()` supports columns with float values.
|
||||
|
||||
_**Function type:** Aggregate or Selector_
|
||||
_**Output data type:** Float | Record_
|
||||
|
||||
```js
|
||||
quantile(
|
||||
column: "_value",
|
||||
q: 0.99,
|
||||
method: "estimate_tdigest",
|
||||
compression: 1000.0
|
||||
)
|
||||
```
|
||||
|
||||
When using the `estimate_tdigest` or `exact_mean` methods, it outputs non-null
|
||||
records with values that fall within the specified quantile.
|
||||
|
||||
When using the `exact_selector` method, it outputs the non-null record with the
|
||||
value that represents the specified quantile.
|
||||
|
||||
## Parameters
|
||||
|
||||
### column
|
||||
The column to use to compute the quantile.
|
||||
Defaults to `"_value"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### q
|
||||
A value between 0 and 1 indicating the desired quantile.
|
||||
|
||||
_**Data type:** Float_
|
||||
|
||||
### method
|
||||
Defines the method of computation.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
The available options are:
|
||||
|
||||
##### estimate_tdigest
|
||||
An aggregate method that uses a [t-digest data structure](https://github.com/tdunning/t-digest)
|
||||
to compute an accurate quantile estimate on large data sources.
|
||||
|
||||
##### exact_mean
|
||||
An aggregate method that takes the average of the two points closest to the quantile value.
|
||||
|
||||
##### exact_selector
|
||||
A selector method that returns the data point for which at least `q` points are less than.
|
||||
|
||||
### compression
|
||||
Indicates how many centroids to use when compressing the dataset.
|
||||
A larger number produces a more accurate result at the cost of increased memory requirements.
|
||||
Defaults to `1000.0`.
|
||||
|
||||
_**Data type:** Float_
|
||||
|
||||
## Examples
|
||||
|
||||
###### Quantile as an aggregate
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "cpu" and
|
||||
r._field == "usage_system")
|
||||
|> quantile(
|
||||
q: 0.99,
|
||||
method: "estimate_tdigest",
|
||||
compression: 1000.0
|
||||
)
|
||||
```
|
||||
|
||||
###### Quantile as a selector
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "cpu" and
|
||||
r._field == "usage_system")
|
||||
|> quantile(
|
||||
q: 0.99,
|
||||
method: "exact_selector"
|
||||
)
|
||||
```
|
||||
{{< duplicate-oss >}}
|
|
@ -41,7 +41,8 @@ The output is constructed as follows:
|
|||
determined from the input tables by the value in `valueColumn` at the row identified by the
|
||||
`rowKey` values and the new column's label.
|
||||
If no value is found, the value is set to `null`.
|
||||
|
||||
- Any column that is not part of the group key or not specified in the `rowKey`,
|
||||
`columnKey` and `valueColumn` parameters is dropped.
|
||||
|
||||
## Parameters
|
||||
|
||||
|
|
|
@ -13,70 +13,4 @@ related:
|
|||
- /{{< latest "influxdb" "v1" >}}/query_language/data_exploration/#the-where-clause, InfluxQL – WHERE
|
||||
---
|
||||
|
||||
The `range()` function filters records based on time bounds.
|
||||
Each input table's records are filtered to contain only records that exist within the time bounds.
|
||||
Records with a `null` value for their time are filtered.
|
||||
Each input table's group key value is modified to fit within the time bounds.
|
||||
Tables where all records exists outside the time bounds are filtered entirely.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
_**Output data type:* Record_
|
||||
|
||||
```js
|
||||
range(start: -15m, stop: now())
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### start
|
||||
The 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()`.
|
||||
|
||||
_**Data type:** Duration | Time | Integer_
|
||||
|
||||
### stop
|
||||
The latest time to include in results.
|
||||
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()`.
|
||||
|
||||
_**Data type:** Duration | Time | Integer_
|
||||
|
||||
{{% note %}}
|
||||
Time values in Flux must be in [RFC3339 format](/influxdb/cloud/reference/flux/language/types#timestamp-format).
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
||||
###### Time range relative to now
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|> range(start: -12h)
|
||||
// ...
|
||||
```
|
||||
|
||||
###### Relative time range
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|> range(start: -12h, stop: -15m)
|
||||
// ...
|
||||
```
|
||||
|
||||
###### Absolute time range
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|> range(start: 2018-05-22T23:30:00Z, stop: 2018-05-23T00:00:00Z)
|
||||
// ...
|
||||
```
|
||||
|
||||
###### Absolute time range with Unix timestamps
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|> range(start: 1527031800, stop: 1527033600)
|
||||
// ...
|
||||
```
|
||||
{{< duplicate-oss >}}
|
|
@ -14,27 +14,4 @@ related:
|
|||
- /{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL – LAST()
|
||||
---
|
||||
|
||||
The `last()` function selects the last non-null record from an input table.
|
||||
|
||||
_**Function type:** Selector_
|
||||
_**Output data type:** Record_
|
||||
|
||||
```js
|
||||
last()
|
||||
```
|
||||
|
||||
{{% warn %}}
|
||||
#### Empty tables
|
||||
`last()` drops empty tables.
|
||||
{{% /warn %}}
|
||||
|
||||
## Examples
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|> range(start:-1h)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "cpu" and
|
||||
r._field == "usage_system"
|
||||
)
|
||||
|> last()
|
||||
```
|
||||
{{< duplicate-oss >}}
|
||||
|
|
|
@ -13,215 +13,4 @@ related:
|
|||
- /influxdb/cloud/reference/flux/stdlib/built-in/transformations/map/
|
||||
---
|
||||
|
||||
The `rows.map()` function is an alternate implementation of [`map()`](/influxdb/cloud/reference/flux/stdlib/built-in/transformations/map/)
|
||||
that is faster, but more limited than `map()`.
|
||||
`rows.map()` cannot modify [groups keys](/influxdb/cloud/reference/glossary/#group-key) and,
|
||||
therefore, does not need to regroup tables.
|
||||
**Attempts to change columns in the group key are ignored.**
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "contrib/jsternberg/rows"
|
||||
|
||||
rows.map( fn: (r) => ({_value: r._value * 100.0}))
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### fn
|
||||
|
||||
A single argument function to apply to each record.
|
||||
The return value must be a record.
|
||||
|
||||
_**Data type:** Function_
|
||||
|
||||
{{% note %}}
|
||||
Use the `with` operator to preserve columns **not** in the group and **not**
|
||||
explicitly mapped in the operation.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
||||
- [Perform mathemtical operations on column values](#perform-mathemtical-operations-on-column-values)
|
||||
- [Preserve all columns in the operation](#preserve-all-columns-in-the-operation)
|
||||
- [Attempt to remap columns in the group key](#attempt-to-remap-columns-in-the-group-key)
|
||||
|
||||
---
|
||||
|
||||
### Perform mathemtical operations on column values
|
||||
The following example returns the square of each value in the `_value` column:
|
||||
|
||||
```js
|
||||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ _value: r._value * r._value }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Important notes
|
||||
The `_time` column is dropped because:
|
||||
|
||||
- It's not in the group key.
|
||||
- It's not explicitly mapped in the operation.
|
||||
- The `with` operator was not used to include existing columns.
|
||||
{{% /note %}}
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
#### Input tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag1 | foo | 0001 | 1.9 |
|
||||
| tag1 | foo | 0002 | 2.4 |
|
||||
| tag1 | foo | 0003 | 2.1 |
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag2 | bar | 0001 | 3.1 |
|
||||
| tag2 | bar | 0002 | 3.8 |
|
||||
| tag2 | bar | 0003 | 1.7 |
|
||||
{{% /flex-content %}}
|
||||
|
||||
{{% flex-content %}}
|
||||
#### Output tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _value |
|
||||
|:--- |:------ | ------:|
|
||||
| tag1 | foo | 3.61 |
|
||||
| tag1 | foo | 5.76 |
|
||||
| tag1 | foo | 4.41 |
|
||||
|
||||
| tag | _field | _value |
|
||||
|:--- |:------ | ------:|
|
||||
| tag2 | bar | 9.61 |
|
||||
| tag2 | bar | 14.44 |
|
||||
| tag2 | bar | 2.89 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
||||
---
|
||||
|
||||
### Preserve all columns in the operation
|
||||
Use the `with` operator in your mapping operation to preserve all columns,
|
||||
including those not in the group key, without explicitly remapping them.
|
||||
|
||||
```js
|
||||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ r with _value: r._value * r._value }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Important notes
|
||||
- The mapping operation remaps the `_value` column.
|
||||
- The `with` operator preserves all other columns not in the group key (`_time`).
|
||||
{{% /note %}}
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
#### Input tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag1 | foo | 0001 | 1.9 |
|
||||
| tag1 | foo | 0002 | 2.4 |
|
||||
| tag1 | foo | 0003 | 2.1 |
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag2 | bar | 0001 | 3.1 |
|
||||
| tag2 | bar | 0002 | 3.8 |
|
||||
| tag2 | bar | 0003 | 1.7 |
|
||||
{{% /flex-content %}}
|
||||
|
||||
{{% flex-content %}}
|
||||
#### Output tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag1 | foo | 0001 | 3.61 |
|
||||
| tag1 | foo | 0002 | 5.76 |
|
||||
| tag1 | foo | 0003 | 4.41 |
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag2 | bar | 0001 | 9.61 |
|
||||
| tag2 | bar | 0002 | 14.44 |
|
||||
| tag2 | bar | 0003 | 2.89 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
||||
---
|
||||
|
||||
### Attempt to remap columns in the group key
|
||||
|
||||
```js
|
||||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ r with tag: "tag3" }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
#### Important notes
|
||||
- Remapping the `tag` column to `"tag3"` is ignored because `tag` is part of the group key.
|
||||
- The `with` operator preserves columns not in the group key (`_time` and `_value`).
|
||||
{{% /note %}}
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
#### Input tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag1 | foo | 0001 | 1.9 |
|
||||
| tag1 | foo | 0002 | 2.4 |
|
||||
| tag1 | foo | 0003 | 2.1 |
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag2 | bar | 0001 | 3.1 |
|
||||
| tag2 | bar | 0002 | 3.8 |
|
||||
| tag2 | bar | 0003 | 1.7 |
|
||||
{{% /flex-content %}}
|
||||
|
||||
{{% flex-content %}}
|
||||
#### Output tables
|
||||
|
||||
**Group key:** `tag,_field`
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag1 | foo | 0001 | 1.9 |
|
||||
| tag1 | foo | 0002 | 2.4 |
|
||||
| tag1 | foo | 0003 | 2.1 |
|
||||
|
||||
| tag | _field | _time | _value |
|
||||
|:--- |:------ |:----- | ------:|
|
||||
| tag2 | bar | 0001 | 3.1 |
|
||||
| tag2 | bar | 0002 | 3.8 |
|
||||
| tag2 | bar | 0003 | 1.7 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
||||
---
|
||||
|
||||
{{% note %}}
|
||||
#### Package author and maintainer
|
||||
**Github:** [@jsternberg](https://github.com/jsternberg)
|
||||
**InfluxDB Slack:** [@Jonathan Sternberg](https://influxdata.com/slack)
|
||||
{{% /note %}}
|
||||
{{< duplicate-oss >}}
|
|
@ -82,7 +82,7 @@ from(bucket: "telegraf")
|
|||
|> range(start: -1h)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "disk" and
|
||||
r._field = "used_percent"
|
||||
r._field == "used_percent"
|
||||
)
|
||||
|> group(columns: ["_measurement"])
|
||||
|> monitor.check(
|
||||
|
|
|
@ -53,6 +53,7 @@ _**Data type:** Float_
|
|||
|
||||
### method
|
||||
Defines the method of computation.
|
||||
Default is `estimate_tdigest`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ The output is constructed as follows:
|
|||
determined from the input tables by the value in `valueColumn` at the row identified by the
|
||||
`rowKey` values and the new column's label.
|
||||
If no value is found, the value is set to `null`.
|
||||
|
||||
- Any column that is not part of the group key or not specified in the `rowKey`,
|
||||
`columnKey` and `valueColumn` parameters is dropped.
|
||||
|
||||
## Parameters
|
||||
|
||||
|
|
|
@ -23,7 +23,18 @@ _**Function type:** Transformation_
|
|||
_**Output data type:* Record_
|
||||
|
||||
```js
|
||||
range(start: -15m, stop: now())
|
||||
range(
|
||||
start: -15m,
|
||||
stop: now()
|
||||
)
|
||||
```
|
||||
|
||||
#### Behavior of start and stop times
|
||||
Results include records with `_time` values greater than or equal to the specified `start`
|
||||
time and less than the specified `stop` time.
|
||||
|
||||
```
|
||||
start <= _time < stop
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
|
|
@ -20,7 +20,7 @@ _**Function type:** Selector_
|
|||
_**Output data type:** Record_
|
||||
|
||||
```js
|
||||
last()
|
||||
last(column: "_value")
|
||||
```
|
||||
|
||||
{{% warn %}}
|
||||
|
@ -28,6 +28,16 @@ last()
|
|||
`last()` drops empty tables.
|
||||
{{% /warn %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
### column
|
||||
Column used to verify the existence of a value.
|
||||
If this column is _null_ in the last record, `last()` returns the previous
|
||||
record with a non-null value.
|
||||
Default is `"_value"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Examples
|
||||
```js
|
||||
from(bucket:"example-bucket")
|
||||
|
|
|
@ -56,7 +56,7 @@ The following example returns the square of each value in the `_value` column:
|
|||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ _value: r._value * r._value }))
|
||||
|> rows.map(fn: (r) => ({ _value: r._value * r._value }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
@ -116,7 +116,7 @@ including those not in the group key, without explicitly remapping them.
|
|||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ r with _value: r._value * r._value }))
|
||||
|> rows.map(fn: (r) => ({ r with _value: r._value * r._value }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
@ -171,7 +171,7 @@ data
|
|||
import "contrib/jsternberg/rows"
|
||||
|
||||
data
|
||||
|> rows.map(fn: (r) ({ r with tag: "tag3" }))
|
||||
|> rows.map(fn: (r) => ({ r with tag: "tag3" }))
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
|
|
@ -82,7 +82,7 @@ from(bucket: "telegraf")
|
|||
|> range(start: -1h)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "disk" and
|
||||
r._field = "used_percent"
|
||||
r._field == "used_percent"
|
||||
)
|
||||
|> group(columns: ["_measurement"])
|
||||
|> monitor.check(
|
||||
|
|
Loading…
Reference in New Issue