From 86c6b468ec338695d3ac6ac2b5cee49685cac247 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 21 Feb 2020 11:26:28 -0700 Subject: [PATCH 1/3] added flux aggregate package, resolves #774 --- .../stdlib/experimental/aggregate/_index.md | 22 ++++++ .../stdlib/experimental/aggregate/rate.md | 77 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md diff --git a/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md b/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md new file mode 100644 index 000000000..4b3c33dea --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux Aggregate package +list_title: Aggregate package +description: > + The Flux Aggregate package provides functions meant to simplify common aggregate operations. + Import the `experimental/aggregate` package. +menu: + v2_0_ref: + name: Aggregate + parent: Experimental +weight: 201 +v2.0/tags: [package] +--- + +The Flux Aggregate package provides functions meant to simplify common aggregate operations. +Import the `experimental/aggregate` package: + +```js +import "experimental/aggregate" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md b/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md new file mode 100644 index 000000000..5042378b5 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md @@ -0,0 +1,77 @@ +--- +title: aggregate.rate() function +description: > + The `aggregate.rate()` function returns the rate of change per windows of time. +menu: + v2_0_ref: + name: aggregate.rate + parent: Aggregate +weight: 301 +--- + +The `aggregate.rate()` function returns the rate of change per windows of time. + +_**Function type:** Transformation_ + +```js +import "experimental/query" + +aggregate.rate( + every: 1m, + groupColumns: ["column1", "column2"], + unit: 1s +) +``` + +## Parameters + +### every +Duration of time windows. + +_**Data type:** Duration_ + +### groupColumns +List of columns to group by. Defaults to `[]`. + +_**Data type:** Array of strings_ + +### unit +The time duration to use when calculating the rate. Defaults to `1s`. + +_**Data type:** Duration_ + +## Examples + +```js +import "experimental/aggregate" + +from(bucket: "example-bucket") + |> range(start: -1h) + |> aggregate.rate(every: 5m, unit: 1m) +``` + +## Function definition +```js +package aggregate + +import "experimental" + +rate = (tables=<-, every, groupColumns=[], unit=1s) => + tables + |> derivative(nonNegative:true, unit:unit) + |> aggregateWindow(every: every, fn : (tables=<-, column) => + tables + |> mean(column: column) + |> group(columns: groupColumns) + |> experimental.group(columns: ["_start", "_stop"], mode:"extend") + |> sum() + ) +``` + +_**Used functions:**_ +[aggregateWindow()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/aggregatewindow/) +[derivative()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/derivative/) +[experimental.group()](/v2.0/reference/flux/stdlib/experimental/group/) +[group()](/v2.0/reference/flux/stdlib/built-in/transformations/group/) +[mean()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mean/) +[sum()](/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/sum/) From 703715dc2c3f677432ea2ead66a1ca74ce7eb31b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 21 Feb 2020 11:42:38 -0700 Subject: [PATCH 2/3] updated description of aggregate package --- .../reference/flux/stdlib/experimental/aggregate/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md b/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md index 4b3c33dea..64720f37a 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md +++ b/content/v2.0/reference/flux/stdlib/experimental/aggregate/_index.md @@ -2,7 +2,7 @@ title: Flux Aggregate package list_title: Aggregate package description: > - The Flux Aggregate package provides functions meant to simplify common aggregate operations. + The Flux Aggregate package provides functions to simplify common aggregate operations. Import the `experimental/aggregate` package. menu: v2_0_ref: @@ -12,7 +12,7 @@ weight: 201 v2.0/tags: [package] --- -The Flux Aggregate package provides functions meant to simplify common aggregate operations. +The Flux Aggregate package provides functions to simplify common aggregate operations. Import the `experimental/aggregate` package: ```js From 74ab9383b606fd17bc87ff287be9566ef5ae3639 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 21 Feb 2020 11:48:54 -0700 Subject: [PATCH 3/3] minor update to experimental.rate description --- .../v2.0/reference/flux/stdlib/experimental/aggregate/rate.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md b/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md index 5042378b5..d5034eab9 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md +++ b/content/v2.0/reference/flux/stdlib/experimental/aggregate/rate.md @@ -1,7 +1,7 @@ --- title: aggregate.rate() function description: > - The `aggregate.rate()` function returns the rate of change per windows of time. + The `aggregate.rate()` function calculates the rate of change per windows of time. menu: v2_0_ref: name: aggregate.rate @@ -9,7 +9,7 @@ menu: weight: 301 --- -The `aggregate.rate()` function returns the rate of change per windows of time. +The `aggregate.rate()` function calculates the rate of change per windows of time. _**Function type:** Transformation_