updated duration related docs to address PR feedback
parent
3c9f64abb5
commit
a8cebd8bfa
|
@ -113,8 +113,8 @@ dataSet
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
The `every` parameter supports all [duration values](/v2.0/reference/flux/language/types/#duration-types),
|
The `every` parameter supports all [valid duration units](/v2.0/reference/flux/language/types/#duration-types),
|
||||||
including calendar month (`1mo`) and year (`1y`).
|
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
Each window of time is output in its own table containing all records that fall within the window.
|
Each window of time is output in its own table containing all records that fall within the window.
|
||||||
|
|
|
@ -61,8 +61,8 @@ Use the `every` parameter to define a duration of each window.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
#### Calendar months and years
|
#### Calendar months and years
|
||||||
`every` supports all [duration values](/v2.0/reference/flux/language/types/#duration-types),
|
`every` supports all [valid duration units](/v2.0/reference/flux/language/types/#duration-types),
|
||||||
including **calendar months (`1mo`) and years (`1y`)**.
|
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
For this example, window data in five minute intervals (`5m`).
|
For this example, window data in five minute intervals (`5m`).
|
||||||
|
|
|
@ -12,7 +12,7 @@ weight: 501
|
||||||
related:
|
related:
|
||||||
- /v2.0/query-data/flux/window-aggregate/
|
- /v2.0/query-data/flux/window-aggregate/
|
||||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#aggregations, InfluxQL – Aggregate functions
|
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#aggregations, InfluxQL – Aggregate functions
|
||||||
- https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-group-by-clause, InfluxQL – GROUP BY time()
|
- https://docs.influxdata.com/influxdb/latest/query_language/explore-data/#the-group-by-clause, InfluxQL – GROUP BY time()
|
||||||
---
|
---
|
||||||
|
|
||||||
The `aggregateWindow()` function applies an aggregate or selector function
|
The `aggregateWindow()` function applies an aggregate or selector function
|
||||||
|
@ -51,8 +51,8 @@ The duration of windows.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
#### Calendar months and years
|
#### Calendar months and years
|
||||||
`every` supports all [duration values](/v2.0/reference/flux/language/types/#duration-types),
|
`every` supports all [valid duration units](/v2.0/reference/flux/language/types/#duration-types),
|
||||||
including **calendar months (`1mo`) and years (`1y`)**.
|
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
_**Data type:** Duration_
|
_**Data type:** Duration_
|
||||||
|
@ -97,15 +97,23 @@ Defaults to `true`.
|
||||||
_**Data type:** Boolean_
|
_**Data type:** Boolean_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
The examples below use a `data` variable to represent a filtered data set.
|
||||||
##### Using an aggregate function with default parameters
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
from(bucket: "example-bucket")
|
data = from(bucket: "example-bucket")
|
||||||
|> range(start: -1h)
|
|> range(start: -1h)
|
||||||
|> filter(fn: (r) =>
|
|> filter(fn: (r) =>
|
||||||
r._measurement == "mem" and
|
r._measurement == "mem" and
|
||||||
r._field == "used_percent")
|
r._field == "used_percent")
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Use an aggregate function with default parameters
|
||||||
|
The following example uses the default parameters of the
|
||||||
|
[`mean()` function](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/)
|
||||||
|
to aggregate time-based windows:
|
||||||
|
|
||||||
|
```js
|
||||||
|
data
|
||||||
|> aggregateWindow(
|
|> aggregateWindow(
|
||||||
every: 5m,
|
every: 5m,
|
||||||
fn: mean
|
fn: mean
|
||||||
|
@ -113,15 +121,11 @@ from(bucket: "example-bucket")
|
||||||
```
|
```
|
||||||
##### Specify parameters of the aggregate function
|
##### Specify parameters of the aggregate function
|
||||||
To use functions that don't provide defaults for required parameters with `aggregateWindow()`,
|
To use functions that don't provide defaults for required parameters with `aggregateWindow()`,
|
||||||
define an anonymous function with `column` and `tables` parameters that pipe-forward
|
define an anonymous function with `column` and `tables` parameters that pipes-forward
|
||||||
tables into the aggregate or selector function with all required parameters defined:
|
tables into the aggregate or selector function with all required parameters defined:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
from(bucket: "example-bucket")
|
data
|
||||||
|> range(start: -1h)
|
|
||||||
|> filter(fn: (r) =>
|
|
||||||
r._measurement == "mem" and
|
|
||||||
r._field == "used_percent")
|
|
||||||
|> aggregateWindow(
|
|> aggregateWindow(
|
||||||
column: "_value",
|
column: "_value",
|
||||||
every: 5m,
|
every: 5m,
|
||||||
|
@ -131,11 +135,7 @@ from(bucket: "example-bucket")
|
||||||
|
|
||||||
##### Window and aggregate by calendar month
|
##### Window and aggregate by calendar month
|
||||||
```js
|
```js
|
||||||
from(bucket: "example-bucket")
|
data
|
||||||
|> range(start: -1y)
|
|
||||||
|> filter(fn: (r) =>
|
|
||||||
r._measurement == "mem" and
|
|
||||||
r._field == "used_percent")
|
|
||||||
|> aggregateWindow(every: 1mo, fn: mean)
|
|> aggregateWindow(every: 1mo, fn: mean)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ window(
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
#### Calendar months and years
|
#### Calendar months and years
|
||||||
`every`, `period`, and `offset` support all [duration values](/v2.0/reference/flux/language/types/#duration-types),
|
`every`, `period`, and `offset` support all [valid duration units](/v2.0/reference/flux/language/types/#duration-types),
|
||||||
including **calendar months (`1mo`) and years (`1y`)**.
|
including **calendar months (`1mo`)** and **years (`1y`)**.
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
### every
|
### every
|
||||||
|
|
Loading…
Reference in New Issue