Merge pull request #390 from influxdata/alpha-17

Alpha 17
pull/395/head
kelseiv 2019-08-14 13:27:48 -07:00 committed by GitHub
commit bb539baef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 1051 additions and 98 deletions

View File

@ -27,7 +27,7 @@ This article describes how to get started with InfluxDB OSS. To get started with
### Download and install InfluxDB v2.0 alpha
Download InfluxDB v2.0 alpha for macOS.
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.16_darwin_amd64.tar.gz" download>InfluxDB v2.0 alpha (macOS)</a>
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.17_darwin_amd64.tar.gz" download>InfluxDB v2.0 alpha (macOS)</a>
### Unpackage the InfluxDB binaries
Unpackage the downloaded archive.
@ -36,7 +36,7 @@ _**Note:** The following commands are examples. Adjust the file paths to your ow
```sh
# Unpackage contents to the current working directory
gunzip -c ~/Downloads/influxdb_2.0.0-alpha.16_darwin_amd64.tar.gz | tar xopf -
gunzip -c ~/Downloads/influxdb_2.0.0-alpha.17_darwin_amd64.tar.gz | tar xopf -
```
If you choose, you can place `influx` and `influxd` in your `$PATH`.
@ -44,7 +44,7 @@ You can also prefix the executables with `./` to run then in place.
```sh
# (Optional) Copy the influx and influxd binary to your $PATH
sudo cp influxdb_2.0.0-alpha.16_darwin_amd64/{influx,influxd} /usr/local/bin/
sudo cp influxdb_2.0.0-alpha.17_darwin_amd64/{influx,influxd} /usr/local/bin/
```
{{% note %}}
@ -90,8 +90,8 @@ influxd --reporting-disabled
### Download and install InfluxDB v2.0 alpha
Download the InfluxDB v2.0 alpha package appropriate for your chipset.
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.16_linux_amd64.tar.gz" download >InfluxDB v2.0 alpha (amd64)</a>
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.16_linux_arm64.tar.gz" download >InfluxDB v2.0 alpha (arm)</a>
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.17_linux_amd64.tar.gz" download >InfluxDB v2.0 alpha (amd64)</a>
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb_2.0.0-alpha.17_linux_arm64.tar.gz" download >InfluxDB v2.0 alpha (arm)</a>
### Place the executables in your $PATH
Unpackage the downloaded archive and place the `influx` and `influxd` executables in your system `$PATH`.
@ -100,10 +100,10 @@ _**Note:** The following commands are examples. Adjust the file names, paths, an
```sh
# Unpackage contents to the current working directory
tar xvzf path/to/influxdb_2.0.0-alpha.16_linux_amd64.tar.gz
tar xvzf path/to/influxdb_2.0.0-alpha.17_linux_amd64.tar.gz
# Copy the influx and influxd binary to your $PATH
sudo cp influxdb_2.0.0-alpha.16_linux_amd64/{influx,influxd} /usr/local/bin/
sudo cp influxdb_2.0.0-alpha.17_linux_amd64/{influx,influxd} /usr/local/bin/
```
{{% note %}}

View File

@ -16,12 +16,13 @@ influxd inspect [subcommand]
```
## Subcommands
| Subcommand | Description |
|:---------- |:----------- |
| [export-blocks](/v2.0/reference/cli/influxd/inspect/export-blocks/) | Export block data |
| [report-tsm](/v2.0/reference/cli/influxd/inspect/report-tsm/) | Run TSM report |
| [verify-tsm](/v2.0/reference/cli/influxd/inspect/verify-tsm/) | Check the consistency of TSM files |
| [verify-wal](/v2.0/reference/cli/influxd/inspect/verify-wal/) | Check for corrupt WAL files |
| Subcommand | Description |
|:---------- |:----------- |
| [export-blocks](/v2.0/reference/cli/influxd/inspect/export-blocks/) | Export block data |
| [report-tsi](/v2.0/reference/cli/influxd/inspect/report-tsi/) | Report the cardinality of TSI files |
| [report-tsm](/v2.0/reference/cli/influxd/inspect/report-tsm/) | Run TSM report |
| [verify-tsm](/v2.0/reference/cli/influxd/inspect/verify-tsm/) | Check the consistency of TSM files |
| [verify-wal](/v2.0/reference/cli/influxd/inspect/verify-wal/) | Check for corrupt WAL files |
## Flags
| Flag | Description |

View File

@ -0,0 +1,44 @@
---
title: influxd inspect report-tsi
description: >
The `influxd inspect report-tsi` command analyzes Time Series Index (TSI) files
in a storage directory and reports the cardinality of data stored in the files.
v2.0/tags: [tsi, cardinality, inspect]
menu:
v2_0_ref:
parent: influxd inspect
weight: 301
---
The `influxd inspect report-tsi` command analyzes Time Series Index (TSI) files
in a storage directory and reports the cardinality of data stored in the files
by organization and bucket.
## Output details
`influxd inspect report-tsi` outputs the following:
- All organizations and buckets in the index.
- The series cardinality within each organization and bucket.
- Time to read the index.
When the `--measurements` flag is included, series cardinality is grouped by:
- organization
- bucket
- measurement
## Usage
```sh
influxd inspect report-tsi [flags]
```
## Flags
| Flag | Description | Input Type |
|:---- |:----------- |:----------:|
| `--bucket-id` | Process data for specified bucket ID. _Requires `org-id` flag to be set._ | string |
| `-h`, `--help` | View help for `report-tsi`. | |
| `-m`, `--measurements` | Group cardinality by measurements. | |
| `-o`, `--org-id` | Process data for specified organization ID. | string |
| `--path` | Specify path to index. Defaults to `~/.influxdbv2/engine/index`. | string |
| `--series-file` | Specify path to series file. Defaults to `~/.influxdbv2/engine/_series`. | string |
| `-t`, `-top` | Limit results to the top n. | integer |

View File

@ -10,7 +10,8 @@ menu:
weight: 501
---
The `aggregateWindow()` function applies an aggregate function to fixed windows of time.
The `aggregateWindow()` function applies an aggregate or selector function
(any function with a `column` parameter) to fixed windows of time.
_**Function type:** Aggregate_
@ -25,7 +26,7 @@ aggregateWindow(
)
```
As data is windowed into separate tables and aggregated, the `_time` column is dropped from each group key.
As data is windowed into separate tables and processed, the `_time` column is dropped from each group key.
This function copies the timestamp from a remaining column into the `_time` column.
View the [function definition](#function-definition).
@ -48,7 +49,7 @@ The [aggregate function](/v2.0/reference/flux/functions/built-in/transformations
_**Data type:** Function_
{{% note %}}
Only aggregate functions with a `column` parameter (singular) work with `aggregateWindow()`.
Only aggregate and selector functions with a `column` parameter (singular) work with `aggregateWindow()`.
{{% /note %}}
### column
@ -95,11 +96,10 @@ from(bucket: "example-bucket")
fn: mean
)
```
###### Specifying parameters of the aggregate function
To use `aggregateWindow()` aggregate functions that don't provide defaults for required parameters,
for the `fn` parameter, define an anonymous function with `columns` and `tables` parameters
that pipe-forwards tables into the aggregate function with all required parameters defined:
###### Specify parameters of the aggregate function
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
tables into the aggregate or selector function with all required parameters defined:
```js
from(bucket: "example-bucket")

View File

@ -0,0 +1,110 @@
---
title: chandeMomentumOscillator() function
description: >
The `chandeMomentumOscillator()` function applies the technical momentum indicator
developed by Tushar Chande.
menu:
v2_0_ref:
name: chandeMomentumOscillator
parent: built-in-aggregates
weight: 501
related:
- https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#triple-exponential-moving-average, InfluxQL CHANDE_MOMENTUM_OSCILLATOR()
---
The `chandeMomentumOscillator()` function applies the technical momentum indicator
developed by Tushar Chande.
_**Function type:** Aggregate_
```js
chandeMomentumOscillator(
n: 10,
columns: ["_value"]
)
```
The Chande Momentum Oscillator (CMO) indicator calculates the difference between
the sum of all recent data points with values greater than the median value of the data set
and the sum of all recent data points with values lower than the median value of the data set,
then divides the result by the sum of all data movement over a given time period.
It then multiplies the result by 100 and returns a value between -100 and +100.
## Parameters
### n
The period or number of points to use in the calculation.
_**Data type: Integer**_
### columns
The columns to operate on.
Defaults to `["_value"]`.
_**Data type: Array of Strings**_
## Examples
#### Table transformation with a ten point Chande Momentum Oscillator
###### Input table
| _time | _value |
|:-----:|:------:|
| 0001 | 1 |
| 0002 | 2 |
| 0003 | 3 |
| 0004 | 4 |
| 0005 | 5 |
| 0006 | 6 |
| 0007 | 7 |
| 0008 | 8 |
| 0009 | 9 |
| 0010 | 10 |
| 0011 | 11 |
| 0012 | 12 |
| 0013 | 13 |
| 0014 | 14 |
| 0015 | 15 |
| 0016 | 14 |
| 0017 | 13 |
| 0018 | 12 |
| 0019 | 11 |
| 0020 | 10 |
| 0021 | 9 |
| 0022 | 8 |
| 0023 | 7 |
| 0024 | 6 |
| 0025 | 5 |
| 0026 | 4 |
| 0027 | 3 |
| 0028 | 2 |
| 0029 | 1 |
###### Query
```js
// ...
|> chandeMomentumOscillator(n: 10)
```
###### Output table
| _time | _value |
|:-----:|:------:|
| 0011 | 100 |
| 0012 | 100 |
| 0013 | 100 |
| 0014 | 100 |
| 0015 | 100 |
| 0016 | 80 |
| 0017 | 60 |
| 0018 | 40 |
| 0019 | 20 |
| 0020 | 0 |
| 0021 | -20 |
| 0022 | -40 |
| 0023 | -60 |
| 0024 | -80 |
| 0025 | -100 |
| 0026 | -100 |
| 0027 | -100 |
| 0028 | -100 |
| 0029 | -100 |

View File

@ -17,7 +17,11 @@ _**Function type:** Aggregate_
_**Output data type:** Float_
```js
difference(nonNegative: false, columns: ["_value"])
difference(
nonNegative: false,
columns: ["_value"],
keepFirst: false
)
```
## Parameters
@ -34,6 +38,13 @@ Defaults to `["_value"]`.
_**Data type:** Array of Strings_
### keepFirst
Indicates the first row should be kept.
If `true`, the difference will be `null`.
Defaults to `false`.
_**Data type:** Boolean_
## Subtraction rules for numeric types
- The difference between two non-null values is their algebraic difference;
or `null`, if the result is negative and `nonNegative: true`;
@ -90,6 +101,20 @@ from(bucket: "example-bucket")
| 0004 | 6 | tv |
| 0005 | null | tv |
#### With keepFirst set to true
```js
|> difference(nonNegative: false, keepfirst: true):
```
###### Output table
| _time | _value | tag |
|:-----:|:------:|:---:|
| 0001 | null | tv |
| 0002 | null | tv |
| 0003 | -2 | tv |
| 0004 | 6 | tv |
| 0005 | null | tv |
<hr style="margin-top:4rem"/>
##### Related InfluxQL functions and statements:

View File

@ -0,0 +1,63 @@
---
title: doubleEMA() function
description: >
The `doubleEMA()` function calculates the exponential moving average of values
grouped into `n` number of points, giving more weight to recent data at double
the rate of `exponentialMovingAverage()`.
menu:
v2_0_ref:
name: doubleEMA
parent: built-in-aggregates
weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
- https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#double-exponential-moving-average, InfluxQL DOUBLE_EXPONENTIAL_MOVING_AVERAGE()
---
The `doubleEMA()` function calculates the exponential moving average of values in
the `_value` column grouped into `n` number of points, giving more weight to recent
data at double the rate of [`exponentialMovingAverage()`](/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/).
_**Function type:** Aggregate_
```js
doubleEMA(n: 5)
```
##### Double exponential moving average rules
- A double exponential moving average is defined as `doubleEMA = 2 * EMA_N - EMA of EMA_N`.
- `EMA` is an exponential moving average.
- `N = n` is the period used to calculate the EMA.
- A true double exponential moving average requires at least `2 * n - 1` values.
If not enough values exist to calculate the double EMA, it returns a `NaN` value.
- `doubleEMA()` inherits all [exponential moving average rules](/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/#exponential-moving-average-rules).
## Parameters
### n
The number of points to average.
_**Data type:** Integer_
## Examples
#### Calculate a five point double exponential moving average
```js
from(bucket: "example-bucket"):
|> range(start: -12h)
|> doubleEMA(n: 5)
```
## Function definition
```js
doubleEMA = (n, tables=<-) =>
tables
|> exponentialMovingAverage(n:n)
|> duplicate(column:"_value", as:"ema")
|> exponentialMovingAverage(n:n)
|> map(fn: (r) => ({r with _value: 2.0 * r.ema - r._value}))
|> drop(columns: ["ema"])
```

View File

@ -1,8 +1,8 @@
---
title: exponentialMovingAverage() function
description: >
The `exponentialMovingAverage()` function calculates the exponential moving average
of values grouped into `n` number of points, giving more weight to recent data.
The `exponentialMovingAverage()` function calculates the exponential moving average of values
in the `_value` column grouped into `n` number of points, giving more weight to recent data.
menu:
v2_0_ref:
name: exponentialMovingAverage
@ -11,22 +11,21 @@ weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/
- https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#exponential-moving-average, InfluxQL EXPONENTIAL_MOVING_AVERAGE()
---
The `exponentialMovingAverage()` function calculates the exponential moving average
of values grouped into `n` number of points, giving more weight to recent data.
The `exponentialMovingAverage()` function calculates the exponential moving average of values
in the `_value` column grouped into `n` number of points, giving more weight to recent data.
_**Function type:** Aggregate_
```js
exponentialMovingAverage(
n: 5,
columns: ["_value"]
)
exponentialMovingAverage(n: 5)
```
##### Exponential moving average rules:
##### Exponential moving average rules
- The first value of an exponential moving average over `n` values is the
algebraic mean of `n` values.
- Subsequent values are calculated as `y(t) = x(t) * k + y(t-1) * (1 - k)`, where:
@ -43,11 +42,6 @@ The number of points to average.
_**Data type:** Integer_
### columns
Columns to operate on. _Defaults to `["_value"]`_.
_**Data type:** Array of Strings_
## Examples
#### Calculate a five point exponential moving average
@ -60,23 +54,20 @@ from(bucket: "example-bucket"):
#### Table transformation with a two point exponential moving average
###### Input table:
| _time | A | B | C | tag |
|:-----:|:----:|:----:|:----:|:---:|
| 0001 | 2 | null | 2 | tv |
| 0002 | null | 10 | 4 | tv |
| 0003 | 8 | 20 | 5 | tv |
| _time | tag | _value |
|:-----:|:---:|:------:|
| 0001 | tv | null |
| 0002 | tv | 10 |
| 0003 | tv | 20 |
###### Query:
```js
// ...
|> exponentialMovingAverage(
n: 2,
columns: ["A", "B", "C"]
)
|> exponentialMovingAverage(n: 2)
```
###### Output table:
| _time | A | B | C | tag |
|:-----:|:----:|:----:|:----:|:---:|
| 0002 | 2 | 10 | 3 | tv |
| 0003 | 6 | 16.67| 4.33 | tv |
| _time | tag | _value |
|:-----:|:---:|:------:|
| 0002 | tv | 10 |
| 0003 | tv | 16.67 |

View File

@ -0,0 +1,114 @@
---
title: holtWinters() function
description: >
The `holtWinters()` function applies the Holt-Winters forecasting method to input tables.
aliases:
- /v2.0/reference/flux/functions/transformations/aggregates/holtwinters
menu:
v2_0_ref:
name: holtWinters
parent: built-in-aggregates
weight: 501
related:
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#holt-winters, InfluxQL HOLT_WINTERS()
---
The `holtWinters()` function applies the Holt-Winters forecasting method to input tables.
_**Function type:** Aggregate_
_**Output data type:** Float_
```js
holtWinters(
n: 10,
seasonality: 4,
interval: 30d,
withFit: false,
timeColumn: "_time",
column: "_value",
)
```
The Holt-Winters method predicts [`n`](#n) seasonally-adjusted values for the
specified [`column`](#column) at the specified [`interval`](#interval).
For example, if `interval` is `6m` and `n` is `3`, results include three predicted
values six minutes apart.
#### Seasonality
[`seasonality`](#seasonality) delimits the length of a seasonal pattern according to `interval`.
If your `interval` is `2m` and `seasonality` is `4`, then the seasonal pattern occurs every
eight minutes or every four data points.
If data doesn't have a seasonal pattern, set `seasonality` to `0`.
#### Space values evenly in time
`holtWinters()` expects values evenly spaced in time.
To ensure `holtWinters()` values are spaced evenly in time, the following rules apply:
- Data is grouped into time-based "buckets" determined by the `interval`.
- If a bucket includes many values, the first value is used.
- If a bucket includes no values, a missing value (`null`) is added for that bucket.
By default, `holtWinters()` uses the first value in each time bucket to run the Holt-Winters calculation.
To specify other values to use in the calculation, use:
- [`window()`](/v2.0/reference/flux/functions/built-in/transformations/window/)
with [selectors](/v2.0/reference/flux/functions/built-in/transformations/selectors/)
or [aggregates](/v2.0/reference/flux/functions/built-in/transformations/aggregates/)
- [`aggregateWindow()`](/v2.0/reference/flux/functions/built-in/transformations/aggregates/aggregatewindow)
#### Fitted model
The `holtWinters()` function applies the [Nelder-Mead optimization](https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method)
to include "fitted" data points in results when [`withFit`](#withfit) is set to `true`.
#### Null timestamps
`holtWinters()` discards rows with `null` timestamps before running the Holt-Winters calculation.
#### Null values
`holtWinters()` treats `null` values as missing data points and includes them in the Holt-Winters calculation.
## Parameters
### n
The number of values to predict.
_**Data type: Integer**_
### seasonality
The number of points in a season.
Defaults to `0`.
_**Data type: Integer**_
### interval
The interval between two data points.
_**Data type: Duration**_
### withFit
Return [fitted data](#fitted-model) in results.
Defaults to `false`.
_**Data type: Boolean**_
### timeColumn
The time column to use.
Defaults to `"_time"`.
_**Data type: String**_
### column
The column to operate on.
Defaults to `"_value"`.
_**Data type: String**_
## Examples
##### Use aggregateWindow to prepare data for holtWinters
```js
from(bucket: "example-bucket")
|> range(start: -7y)
|> filter(fn: (r) => r._field == "water_level")
|> aggregateWindow(every: 379m, fn: first).
|> holtWinters(n: 10, seasonality: 4, interval: 379m)
```

View File

@ -10,21 +10,21 @@ weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
---
The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
The `movingAverage()` function calculates the mean of values in the `_values` column
grouped into `n` number of points.
_**Function type:** Aggregate_
```js
movingAverage(
n: 5,
columns: ["_value"]
)
movingAverage(n: 5)
```
##### Moving average rules:
##### Moving average rules
- The average over a period populated by `n` values is equal to their algebraic mean.
- The average over a period populated by only `null` values is `null`.
- Moving averages skip `null` values.
@ -38,11 +38,6 @@ The number of points to average.
_**Data type:** Integer_
### columns
Columns to operate on. _Defaults to `["_value"]`_.
_**Data type:** Array of Strings_
## Examples
#### Calculate a five point moving average
@ -52,36 +47,23 @@ from(bucket: "example-bucket"):
|> movingAverage(n: 5)
```
#### Calculate a ten point moving average
```js
movingAverage = (every, period, column="_value", tables=<-) =>
tables
|> window(every: every, period: period)
|> mean(column: column)
|> duplicate(column: "_stop", as: "_time")
|> window(every: inf)
```
#### Table transformation with a two point moving average
###### Input table:
| _time | A | B | C | D | tag |
|:-----:|:----:|:----:|:----:|:----:|:---:|
| 0001 | null | 1 | 2 | null | tv |
| 0002 | 6 | 2 | null | null | tv |
| 0003 | 4 | null | 4 | 4 | tv |
| _time | tag | _value |
|:-----:|:---:|:------:|
| 0001 | tv | null |
| 0002 | tv | 6 |
| 0003 | tv | 4 |
###### Query:
```js
// ...
|> movingAverage(
n: 2,
columns: ["A", "B", "C", "D"]
)
|> movingAverage(n: 2 )
```
###### Output table:
| _time | A | B | C | D | tag |
|:-----:|:----:|:----:|:----:|:----:|:---:|
| 0002 | 6 | 1.5 | 2 | null | tv |
| 0003 | 5 | 2 | 4 | 4 | tv |
| _time | tag | _value |
|:-----:|:---:|:------:|
| 0002 | tv | 6 |
| 0003 | tv | 5 |

View File

@ -0,0 +1,103 @@
---
title: relativeStrengthIndex() function
description: >
The `relativeStrengthIndex()` function measures the relative speed and change of
values in an input table.
menu:
v2_0_ref:
name: relativeStrengthIndex
parent: built-in-aggregates
weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
- https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#relative-strength-index, InfluxQL RELATIVE_STRENGTH_INDEX()
---
The `relativeStrengthIndex()` function measures the relative speed and change of
values in an input table.
_**Function type:** Aggregate_
```js
relativeStrengthIndex(
n: 5,
columns: ["_value"]
)
```
##### Relative strength index rules
- The general equation for calculating a relative strength index (RSI) is
`RSI = 100 - (100 / (1 + (AVG GAIN / AVG LOSS)))`.
- For the first value of the RSI, `AVG GAIN` and `AVG LOSS` are averages of the `n` period.
- For subsequent calculations:
- `AVG GAIN` = `((PREVIOUS AVG GAIN) * (n - 1)) / n`
- `AVG LOSS` = `((PREVIOUS AVG LOSS) * (n - 1)) / n`
- `relativeStrengthIndex()` ignores `null` values.
## Parameters
### n
The number of values to use to calculate the RSI.
_**Data type:** Integer_
### columns
Columns to operate on. _Defaults to `["_value"]`_.
_**Data type:** Array of Strings_
## Examples
#### Calculate a five point relative strength index
```js
from(bucket: "example-bucket"):
|> range(start: -12h)
|> relativeStrengthIndex(n: 5)
```
#### Table transformation with a ten point RSI
###### Input table:
| _time | A | B | tag |
|:-----:|:----:|:----:|:---:|
| 0001 | 1 | 1 | tv |
| 0002 | 2 | 2 | tv |
| 0003 | 3 | 3 | tv |
| 0004 | 4 | 4 | tv |
| 0005 | 5 | 5 | tv |
| 0006 | 6 | 6 | tv |
| 0007 | 7 | 7 | tv |
| 0008 | 8 | 8 | tv |
| 0009 | 9 | 9 | tv |
| 0010 | 10 | 10 | tv |
| 0011 | 11 | 11 | tv |
| 0012 | 12 | 12 | tv |
| 0013 | 13 | 13 | tv |
| 0014 | 14 | 14 | tv |
| 0015 | 15 | 15 | tv |
| 0016 | 16 | 16 | tv |
| 0017 | 17 | null | tv |
| 0018 | 18 | 17 | tv |
###### Query:
```js
// ...
|> relativeStrengthIndex(
n: 10,
columns: ["A", "B"]
)
```
###### Output table:
| _time | A | B | tag |
|:-----:|:----:|:----:|:---:|
| 0011 | 100 | 100 | tv |
| 0012 | 100 | 100 | tv |
| 0013 | 100 | 100 | tv |
| 0014 | 100 | 100 | tv |
| 0015 | 100 | 100 | tv |
| 0016 | 90 | 90 | tv |
| 0017 | 81 | 90 | tv |
| 0018 | 72.9 | 81 | tv |

View File

@ -11,6 +11,8 @@ weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/tripleema/
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
---

View File

@ -0,0 +1,68 @@
---
title: tripleEMA() function
description: >
The `tripleEMA()` function calculates the exponential moving average of values
grouped into `n` number of points, giving more weight to recent data with less lag
than `exponentialMovingAverage()` and `doubleEMA()`.
menu:
v2_0_ref:
name: tripleEMA
parent: built-in-aggregates
weight: 501
related:
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/movingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/timedmovingaverage/
- /v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/
- https://docs.influxdata.com/influxdb/v1.7/query_language/functions/#triple-exponential-moving-average, InfluxQL TRIPLE_EXPONENTIAL_MOVING_AVERAGE()
---
The `tripleEMA()` function calculates the exponential moving average of values in
the `_value` column grouped into `n` number of points, giving more weight to recent
data with less lag than
[`exponentialMovingAverage()`](/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/)
and [`doubleEMA()`](/v2.0/reference/flux/functions/built-in/transformations/aggregates/doubleema/).
_**Function type:** Aggregate_
```js
tripleEMA(n: 5)
```
##### Triple exponential moving average rules
- A triple exponential moving average is defined as `tripleEMA = (3 * EMA_1) - (3 * EMA_2) + EMA_3`.
- `EMA_1` is the exponential moving average of the original data.
- `EMA_2` is the exponential moving average of `EMA_1`.
- `EMA_3` is the exponential moving average of `EMA_2`.
- A true triple exponential moving average requires at least requires at least `3 * n - 2` values.
If not enough values exist to calculate the triple EMA, it returns a `NaN` value.
- `tripleEMA()` inherits all [exponential moving average rules](/v2.0/reference/flux/functions/built-in/transformations/aggregates/exponentialmovingaverage/#exponential-moving-average-rules).
## Parameters
### n
The number of points to average.
_**Data type:** Integer_
## Examples
#### Calculate a five point triple exponential moving average
```js
from(bucket: "example-bucket"):
|> range(start: -12h)
|> tripleEMA(n: 5)
```
## Function definition
```js
tripleEMA = (n, tables=<-) =>
tables
|> exponentialMovingAverage(n:n)
|> duplicate(column:"_value", as:"ema1")
|> exponentialMovingAverage(n:n)
|> duplicate(column:"_value", as:"ema2")
|> exponentialMovingAverage(n:n)
|> map(fn: (r) => ({r with _value: 3.0 * r.ema1 - 3.0 * r.ema2 + r._value}))
|> drop(columns: ["ema1", "ema2"])
```

View File

@ -0,0 +1,55 @@
---
title: hourSelection() function
description: >
The `hourSelection()` function retains all rows with time values in a specified hour range.
Hours are specified in military time.
aliases:
- /v2.0/reference/flux/functions/transformations/hourSelection
menu:
v2_0_ref:
name: hourSelection
parent: built-in-transformations
weight: 401
---
The `hourSelection()` function retains all rows with time values in a specified hour range.
_**Function type:** Transformation_
```js
hourSelection(
start: 9,
stop: 17,
timeColumn: "_time"
)
```
## Parameters
### start
The first hour of the hour range (inclusive).
Hours range from `[0-23]`.
_**Data type:** Integer_
### stop
The last hour of the hour range (inclusive).
Hours range from `[0-23]`.
_**Data type:** Integer_
### timeColumn
The column that contains the time value.
Default is `"_time"`.
_**Data type:** String_
## Examples
##### Use only data from 9am to 5pm
```js
from(bucket:"example-bucket")
|> range(start:-90d)
|> filter(fn: (r) => r._measurement == "foot-traffic" )
|> hourSelection(start: 9, stop: 17)
```

View File

@ -1,6 +1,6 @@
---
title: limit() function
description: The `limit()` function limits the number of records in output tables to a fixed number (n).
description: The `limit()` function limits each output table to the first `n` records.
aliases:
- /v2.0/reference/flux/functions/transformations/limit
menu:
@ -8,18 +8,23 @@ menu:
name: limit
parent: built-in-transformations
weight: 401
related:
- /v2.0/reference/flux/functions/built-in/transformations/tail/
- https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-limit-and-slimit-clauses, InfluxQL LIMIT
---
The `limit()` function limits the number of records in output tables to a fixed number ([`n`](#n)).
One output table is produced for each input table.
Each output table contains the first `n` records after the first `offset` records of the input table.
If the input table has less than `offset + n` records, all records except the first `offset` ones are output.
The `limit()` function limits each output table to the first [`n`](#n) records.
The function produces one output table for each input table.
Each output table contains the first `n` records after the [`offset`](#offset).
If the input table has less than `offset + n` records, `limit()` outputs all records after the `offset`.
_**Function type:** Filter_
_**Output data type:** Object_
_**Function type:** Filter_
```js
limit(n:10, offset: 0)
limit(
n:10,
offset: 0
)
```
## Parameters
@ -36,13 +41,10 @@ Defaults to `0`.
_**Data type:** Integer_
## Examples
##### Output the first ten records in each table
```js
from(bucket:"example-bucket")
|> range(start:-1h)
|> limit(n:10, offset: 1)
|> limit(n:10)
```
<hr style="margin-top:4rem"/>
##### Related InfluxQL functions and statements:
[LIMIT](https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-limit-and-slimit-clauses)

View File

@ -0,0 +1,47 @@
---
title: tail() function
description: The `tail()` function limits each output table to the last `n` records.
menu:
v2_0_ref:
name: tail
parent: built-in-transformations
weight: 401
related:
- /v2.0/reference/flux/functions/built-in/transformations/limit/
---
The `tail()` function limits each output table to the last [`n`](#n) records.
The function produces one output table for each input table.
Each output table contains the last `n` records before the [`offset`](#offset).
If the input table has less than `offset + n` records, `tail()` outputs all records before the `offset`.
_**Function type:** Filter_
```js
tail(
n:10,
offset: 0
)
```
## Parameters
### n
The maximum number of records to output.
_**Data type:** Integer_
### offset
The number of records to skip at the end of a table table before limiting to `n`.
Defaults to `0`.
_**Data type:** Integer_
## Examples
##### Output the last ten records in each table
```js
from(bucket:"example-bucket")
|> range(start:-1h)
|> tail(n:10)
```

View File

@ -0,0 +1,31 @@
---
title: date.microsecond() function
description: >
The `date.microsecond()` function returns the microsecond of a specified time.
Results range from `[0-999999]`.
menu:
v2_0_ref:
name: date.microsecond
parent: Date
weight: 301
---
The `date.microsecond()` function returns the microsecond of a specified time.
Results range from `[0-999999]`.
_**Function type:** Transformation_
```js
import "date"
date.microsecond(t: 2019-07-17T12:05:21.012934584Z)
// Returns 12934
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.millisecond() function
description: >
The `date.millisecond()` function returns the millisecond of a specified time.
Results range from `[0-999999]`.
menu:
v2_0_ref:
name: date.millisecond
parent: Date
weight: 301
---
The `date.millisecond()` function returns the millisecond of a specified time.
Results range from `[0-999]`.
_**Function type:** Transformation_
```js
import "date"
date.millisecond(t: 2019-07-17T12:05:21.012934584Z)
// Returns 12
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.nanosecond() function
description: >
The `date.nanosecond()` function returns the nanosecond of a specified time.
Results range from `[0-999999999]`.
menu:
v2_0_ref:
name: date.nanosecond
parent: Date
weight: 301
---
The `date.nanosecond()` function returns the nanosecond of a specified time.
Results range from `[0-999999999]`.
_**Function type:** Transformation_
```js
import "date"
date.nanosecond(t: 2019-07-17T12:05:21.012934584Z)
// Returns 12934584
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.quarter() function
description: >
The `date.quarter()` function returns the quarter of the year for a specified time.
Results range from `[1-4]`.
menu:
v2_0_ref:
name: date.quarter
parent: Date
weight: 301
---
The `date.quarter()` function returns the quarter of the year for a specified time.
Results range from `[1-4]`.
_**Function type:** Transformation_
```js
import "date"
date.quarter(t: 2019-07-17T12:05:21.012Z)
// Returns 3
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,57 @@
---
title: date.truncate() function
description: >
The `date.truncate()` function truncates a time to a specified unit.
menu:
v2_0_ref:
name: date.truncate
parent: Date
weight: 301
---
The `date.truncate()` function truncates a time to a specified unit.
_**Function type:** Transformation_
```js
import "date"
date.truncate(
t: 2019-07-17T12:05:21.012Z
unit: 1s
)
// Returns 2019-07-17T12:05:21.000000000Z
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_
### unit
The unit time to truncate to.
_**Data type:** Duration_
{{% note %}}
Only use `1` and the unit of time to specify the `unit`.
For example: `1s`, `1m`, `1h`.
{{% /note %}}
## Examples
```js
import "date"
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1s)
// Returns 2019-06-03T13:59:01.000000000Z
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1m)
// Returns 2019-06-03T13:59:00.000000000Z
date.truncate(t: "2019-06-03T13:59:01.000000000Z", unit: 1h)
// Returns 2019-06-03T13:00:00.000000000Z
```

View File

@ -0,0 +1,31 @@
---
title: date.week() function
description: >
The `date.week()` function returns the ISO week of the year for a specified time.
Results range from `[1-53]`.
menu:
v2_0_ref:
name: date.week
parent: Date
weight: 301
---
The `date.week()` function returns the ISO week of the year for a specified time.
Results range from `[1-53]`.
_**Function type:** Transformation_
```js
import "date"
date.week(t: 2019-07-17T12:05:21.012Z)
// Returns 29
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,29 @@
---
title: date.year() function
description: >
The `date.year()` function returns the year of a specified time.
menu:
v2_0_ref:
name: date.year
parent: Date
weight: 301
---
The `date.year()` function returns the year of a specified time.
_**Function type:** Transformation_
```js
import "date"
date.year(t: 2019-07-17T12:05:21.012Z)
// Returns 2019
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,22 @@
---
title: Flux runtime package
list_title: Runtime package
description: >
The Flux runtime package includes functions that provide information about the
current Flux runtime. Import the `runtime` package.
menu:
v2_0_ref:
name: Runtime
parent: Flux packages and functions
weight: 202
v2.0/tags: [runtime, functions, package]
---
The Flux runtime package includes functions that provide information about the
current Flux runtime. Import the `runtime` package:
```js
import "runtime"
```
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,20 @@
---
title: runtime.version() function
description: The `runtime.version()` function returns the current Flux version.
menu:
v2_0_ref:
name: runtime.version
parent: Runtime
weight: 401
---
The `runtime.version()` function returns the current Flux version.
_**Function type:** Miscellaneous_
_**Output data type:** String_
```js
import "runtime"
runtime.version()
```

View File

@ -11,13 +11,61 @@ aliases:
---
{{% note %}}
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.37.2**.
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.39.0**.
Though newer versions of Flux may be available, they will not be included with
InfluxDB until the next InfluxDB v2.0 release._
{{% /note %}}
---
## v0.39.0 [2019-08-13]
### Breaking changes
- Implement the scanning components for string expressions.
### Features
- Add `tail()` function.
- Add framework for `http.post()` function.
- Implement `deadman()` function.
- Time arithmetic functions.
- Alerts package.
- Add an experimental `group()` function with mode `extend`.
- Implement the scanning components for string expressions.
- Add `chandeMomentumOscillator()` function.
- Add `hourSelection()` function.
- Add `date.year()` function
### Bug fixes
- Update object to use Invalid type instead of nil monotypes.
- Make it so the alerts package can be defined in pure Flux.
- Close connection after `sql.to()`.
---
## v0.38.0 [2019-08-06]
### Features
- Update selectors to operate on time columns.
- Add `relativeStrengthIndex()` transformation.
- Add double and triple exponential average transformations (`doubleEMA()` and `tripleEMA()`).
- Add `holtWinters()` transformation.
- Add `keepFirst` parameter to `difference()`.
- DatePart equivalent functions.
- Add runtime package.
- Add and subtract duration literal arithmetic.
- Allow `keep()` to run regardless of nonexistent columns.
If all columns given are nonexistent, `keep()` returns an empty table.
- Scanner returns positioning.
### Bug fixes
- Function resolver now keeps track of local assignments that may be evaluated at runtime.
- Fixed InfluxDB test errors.
- Add range to tests to pass in InfluxDB.
- Allow converting a duration to a duration.
- Catch integer overflow and underflow for literals.
---
## v0.37.2 [2019-07-24]
- _General cleanup of internal code._

View File

@ -8,6 +8,21 @@ menu:
weight: 101
---
## v2.0.0-alpha.17 [2019-08-14]
### Features
- Optional gzip compression of the query CSV response.
- Add task types.
- When getting task runs from the API, runs will be returned in order of most recently scheduled first.
### Bug Fixes
- Fix authentication when updating a task with invalid org or bucket.
- Update the documentation link for Telegraf.
- Fix to surface errors properly as task notifications on create.
- Fix limiting of get runs for task.
---
## v2.0.0-alpha.16 [2019-07-25]
### Bug Fixes