commit
108f6e5463
|
@ -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.15_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.16_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.15_darwin_amd64.tar.gz | tar xopf -
|
||||
gunzip -c ~/Downloads/influxdb_2.0.0-alpha.16_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.15_darwin_amd64/{influx,influxd} /usr/local/bin/
|
||||
sudo cp influxdb_2.0.0-alpha.16_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.15_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.15_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.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>
|
||||
|
||||
### 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.15_linux_amd64.tar.gz
|
||||
tar xvzf path/to/influxdb_2.0.0-alpha.16_linux_amd64.tar.gz
|
||||
|
||||
# Copy the influx and influxd binary to your $PATH
|
||||
sudo cp influxdb_2.0.0-alpha.15_linux_amd64/{influx,influxd} /usr/local/bin/
|
||||
sudo cp influxdb_2.0.0-alpha.16_linux_amd64/{influx,influxd} /usr/local/bin/
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
title: sleep() function
|
||||
description: The `sleep()` function delays execution by a specified duration.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: sleep
|
||||
parent: built-in-misc
|
||||
weight: 401
|
||||
---
|
||||
|
||||
The `sleep()` function delays execution by a specified duration.
|
||||
|
||||
_**Function type:** Miscellaneous_
|
||||
|
||||
```js
|
||||
sleep(
|
||||
v: x,
|
||||
duration: 10s
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### v
|
||||
Defines input tables.
|
||||
`sleep()` accepts piped-forward data and passes it on unmodified after the
|
||||
specified [duration](#duration).
|
||||
If data is not piped-forward into `sleep()`, set `v` to specify a stream object.
|
||||
The examples [below](#examples) illustrate how.
|
||||
|
||||
_**Data type:** Object_
|
||||
|
||||
### duration
|
||||
The length of time to delay execution.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
## Examples
|
||||
|
||||
### Delay execution in a chained query
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -1h)
|
||||
|> sleep(duration: 10s)
|
||||
```
|
||||
|
||||
### Delay execution using a stream variable
|
||||
```js
|
||||
x = from(bucket: "example-bucket")
|
||||
|> range(start: -1h)
|
||||
|
||||
sleep(v: x, duration: 10s)
|
||||
```
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
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.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: exponentialMovingAverage
|
||||
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/
|
||||
- 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.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
|
||||
```js
|
||||
exponentialMovingAverage(
|
||||
n: 5,
|
||||
columns: ["_value"]
|
||||
)
|
||||
```
|
||||
|
||||
##### 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:
|
||||
- `y(t)` is the exponential moving average at time `t`.
|
||||
- `x(t)` is the value at time `t`.
|
||||
- `k = 2 / (1 + n)`.
|
||||
- The average over a period populated by only `null` values is `null`.
|
||||
- Exponential moving averages skip `null` values.
|
||||
|
||||
## Parameters
|
||||
|
||||
### n
|
||||
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
|
||||
```js
|
||||
from(bucket: "example-bucket"):
|
||||
|> range(start: -12h)
|
||||
|> exponentialMovingAverage(n: 5)
|
||||
```
|
||||
|
||||
#### 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 |
|
||||
|
||||
###### Query:
|
||||
```js
|
||||
// ...
|
||||
|> exponentialMovingAverage(
|
||||
n: 2,
|
||||
columns: ["A", "B", "C"]
|
||||
)
|
||||
```
|
||||
|
||||
###### Output table:
|
||||
| _time | A | B | C | tag |
|
||||
|:-----:|:----:|:----:|:----:|:---:|
|
||||
| 0002 | 2 | 10 | 3 | tv |
|
||||
| 0003 | 6 | 16.67| 4.33 | tv |
|
|
@ -8,7 +8,6 @@ menu:
|
|||
name: mode
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
draft: true
|
||||
---
|
||||
|
||||
The `mode()` function computes the mode or value that occurs most often in a
|
||||
|
@ -20,6 +19,18 @@ _**Function type:** Aggregate_
|
|||
mode(column: "_value")
|
||||
```
|
||||
|
||||
Multiple modes are returned in a sorted table.
|
||||
If there is no mode, `mode()` returns `null`.
|
||||
|
||||
##### Supported data types
|
||||
|
||||
- String
|
||||
- Float
|
||||
- Integer
|
||||
- UInteger
|
||||
- Boolean
|
||||
- Time
|
||||
|
||||
## Parameters
|
||||
|
||||
### column
|
||||
|
@ -30,7 +41,7 @@ _**Data type:** String_
|
|||
|
||||
## Examples
|
||||
|
||||
###### Mode as an aggregate
|
||||
###### Return the mode of windowed data
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|> filter(fn: (r) =>
|
||||
|
|
|
@ -1,61 +1,58 @@
|
|||
---
|
||||
title: movingAverage() function
|
||||
description: >
|
||||
The `movingAverage()` function calculates the mean of values in a defined time
|
||||
range at a specified frequency.
|
||||
The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: movingAverage
|
||||
parent: built-in-aggregates
|
||||
weight: 501
|
||||
related:
|
||||
- /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/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
The `movingAverage()` function calculates the mean of values in a defined time
|
||||
range at a specified frequency.
|
||||
The `movingAverage()` function calculates the mean of values grouped into `n` number of points.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
|
||||
```js
|
||||
movingAverage(
|
||||
every: 1d,
|
||||
period: 5d,
|
||||
column="_value"
|
||||
n: 5,
|
||||
columns: ["_value"]
|
||||
)
|
||||
```
|
||||
|
||||
##### 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.
|
||||
- If `n` is less than the number of records in a table, `movingAverage` returns
|
||||
the average of the available values.
|
||||
|
||||
## Parameters
|
||||
|
||||
### every
|
||||
The frequency of time windows.
|
||||
### n
|
||||
The number of points to average.
|
||||
|
||||
_**Data type:** Duration_
|
||||
_**Data type:** Integer_
|
||||
|
||||
### period
|
||||
The length of each averaged time window.
|
||||
_A negative duration indicates start and stop boundaries are reversed._
|
||||
### columns
|
||||
Columns to operate on. _Defaults to `["_value"]`_.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
### column
|
||||
The column used to compute the moving average.
|
||||
Defaults to `"_value"`.
|
||||
|
||||
_**Data type:** String_
|
||||
_**Data type:** Array of Strings_
|
||||
|
||||
## Examples
|
||||
|
||||
###### Calculate a five year moving average every year
|
||||
#### Calculate a five point moving average
|
||||
```js
|
||||
from(bucket: "example-bucket"):
|
||||
|> range(start: -7y)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "financial" and
|
||||
r._field == "closing_price"
|
||||
)
|
||||
|> movingAverage(every: 1y, period: 5y)
|
||||
|> range(start: -12h)
|
||||
|> movingAverage(n: 5)
|
||||
```
|
||||
|
||||
## Function definition
|
||||
#### Calculate a ten point moving average
|
||||
```js
|
||||
movingAverage = (every, period, column="_value", tables=<-) =>
|
||||
tables
|
||||
|
@ -65,7 +62,26 @@ movingAverage = (every, period, column="_value", tables=<-) =>
|
|||
|> window(every: inf)
|
||||
```
|
||||
|
||||
<hr style="margin-top:4rem"/>
|
||||
#### Table transformation with a two point moving average
|
||||
|
||||
##### Related InfluxQL functions and statements:
|
||||
[MOVING_AVERAGE()](https://docs.influxdata.com/influxdb/latest/query_language/functions/#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 |
|
||||
|
||||
###### Query:
|
||||
```js
|
||||
// ...
|
||||
|> movingAverage(
|
||||
n: 2,
|
||||
columns: ["A", "B", "C", "D"]
|
||||
)
|
||||
```
|
||||
|
||||
###### Output table:
|
||||
| _time | A | B | C | D | tag |
|
||||
|:-----:|:----:|:----:|:----:|:----:|:---:|
|
||||
| 0002 | 6 | 1.5 | 2 | null | tv |
|
||||
| 0003 | 5 | 2 | 4 | 4 | tv |
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
title: timedMovingAverage() function
|
||||
description: >
|
||||
The `timedMovingAverage()` function calculates the mean of values in a defined time
|
||||
range at a specified frequency.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: timedMovingAverage
|
||||
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/exponentialmovingaverage/
|
||||
- https://docs.influxdata.com/influxdb/latest/query_language/functions/#moving-average, InfluxQL MOVING_AVERAGE()
|
||||
---
|
||||
|
||||
The `timedMovingAverage()` function calculates the mean of values in a defined time
|
||||
range at a specified frequency.
|
||||
|
||||
_**Function type:** Aggregate_
|
||||
|
||||
```js
|
||||
timedMovingAverage(
|
||||
every: 1d,
|
||||
period: 5d,
|
||||
column="_value"
|
||||
)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### every
|
||||
The frequency of time windows.
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
### period
|
||||
The length of each averaged time window.
|
||||
_A negative duration indicates start and stop boundaries are reversed._
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
### column
|
||||
The column used to compute the moving average.
|
||||
Defaults to `"_value"`.
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Examples
|
||||
|
||||
###### Calculate a seven day moving average every day
|
||||
```js
|
||||
from(bucket: "example-bucket"):
|
||||
|> range(start: -7y)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "financial" and
|
||||
r._field == "closing_price"
|
||||
)
|
||||
|> timedMovingAverage(every: 1y, period: 5y)
|
||||
```
|
||||
|
||||
###### Calculate a five year moving average every year
|
||||
```js
|
||||
from(bucket: "example-bucket"):
|
||||
|> range(start: -50d)
|
||||
|> filter(fn: (r) =>
|
||||
r._measurement == "financial" and
|
||||
r._field == "closing_price"
|
||||
)
|
||||
|> timedMovingAverage(every: 1d, period: 7d)
|
||||
```
|
||||
|
||||
## Function definition
|
||||
```js
|
||||
timedMovingAverage = (every, period, column="_value", tables=<-) =>
|
||||
tables
|
||||
|> window(every: every, period: period)
|
||||
|> mean(column:column)
|
||||
|> duplicate(column: "_stop", as: "_time")
|
||||
|> window(every: inf)
|
||||
```
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: elapsed() function
|
||||
description: The `elapsed()` function returns the time between subsequent records.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: elapsed
|
||||
parent: built-in-transformations
|
||||
weight: 401
|
||||
---
|
||||
|
||||
The `elapsed()` function returns the time between subsequent records.
|
||||
Given an input table, `elapsed()` returns the same table without the first record
|
||||
(as elapsed time is not defined) and an additional column containing the elapsed time.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
elapsed(
|
||||
unit: 1s,
|
||||
timeColumn: "_time",
|
||||
columnName: "elapsed"
|
||||
)
|
||||
```
|
||||
|
||||
_`elapsed()` returns an errors if the `timeColumn` is not present in the input table._
|
||||
|
||||
## Parameters
|
||||
|
||||
### unit
|
||||
The unit time to returned.
|
||||
_Defaults to `1s`._
|
||||
|
||||
_**Data type:** Duration_
|
||||
|
||||
### timeColumn
|
||||
The column to use to compute the elapsed time.
|
||||
_Defaults to `"_time"`._
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
### columnName
|
||||
The column to store elapsed times.
|
||||
_Defaults to `"elapsed"`._
|
||||
|
||||
_**Data type:** String_
|
||||
|
||||
## Examples
|
||||
|
||||
##### Calculate the time between points in seconds
|
||||
```js
|
||||
from(bucket: "example-bucket")
|
||||
|> range(start: -5m)
|
||||
|> elapsed(unit: 1s)
|
||||
```
|
|
@ -35,7 +35,7 @@ Absolute start times are defined using timestamps.
|
|||
_**Data type:** Duration or Timestamp_
|
||||
|
||||
### stop
|
||||
Specifies the exclusive newest time to be included in the results. Defaults to `now`.
|
||||
Specifies the newest time to be included in the results. Defaults to `now`.
|
||||
|
||||
Relative stop times are defined using negative durations.
|
||||
Negative durations are relative to now.
|
||||
|
|
|
@ -22,7 +22,7 @@ toBool()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `bool()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toBool = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => bool(v: r._value))
|
||||
|> map(fn:(r) => ({ r with _value: bool(v: r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -10,6 +10,10 @@ menu:
|
|||
weight: 501
|
||||
---
|
||||
|
||||
{{% warn %}}
|
||||
**`toDuration()` was removed in Flux 0.37.**
|
||||
{{% /warn %}}
|
||||
|
||||
The `toDuration()` function converts all values in the `_value` column to durations.
|
||||
|
||||
_**Function type:** Type conversion_
|
||||
|
@ -22,7 +26,7 @@ toDuration()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `duration()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +43,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toDuration = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => duration(v: r._value))
|
||||
|> map(fn:(r) => ({ r with _value: duration(v: r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -22,7 +22,7 @@ toFloat()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `float()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toFloat = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => float(v: r._value))
|
||||
|> map(fn:(r) => ({ r with _value: float(v: r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -22,7 +22,7 @@ toInt()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `int()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toInt = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => int(v: r._value))
|
||||
|> map(fn:(r) => ({ r with _value: int(v: r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -22,7 +22,7 @@ toString()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `string()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toString = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => string(v: r._value))
|
||||
|> map(fn:(r) => ({ r with _value: string(v: r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -22,7 +22,7 @@ toTime()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `time()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toTime = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => time(v:r._value))
|
||||
|> map(fn:(r) => ({ r with _value: time(v:r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -22,7 +22,7 @@ toUInt()
|
|||
{{% note %}}
|
||||
To convert values in a column other than `_value`, define a custom function
|
||||
patterned after the [function definition](#function-definition),
|
||||
but replace the column in the `uint()` function with your desired column.
|
||||
but replace `_value` with your desired column.
|
||||
{{% /note %}}
|
||||
|
||||
## Examples
|
||||
|
@ -39,7 +39,7 @@ from(bucket: "telegraf")
|
|||
```js
|
||||
toUInt = (tables=<-) =>
|
||||
tables
|
||||
|> map(fn:(r) => uint(v:r._value))
|
||||
|> map(fn:(r) => ({ r with _value: uint(v:r._value) }))
|
||||
```
|
||||
|
||||
_**Used functions:**
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: Flux date package
|
||||
list_title: Date package
|
||||
description: >
|
||||
The Flux math package provides basic constants and mathematical functions.
|
||||
Import the `math` package.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/language/built-ins/time-constants/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Date
|
||||
parent: Flux packages and functions
|
||||
weight: 202
|
||||
v2.0/tags: [date, time, functions]
|
||||
---
|
||||
|
||||
The Flux 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]`.
|
||||
|
||||
```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.September = 9
|
||||
date.October = 10
|
||||
date.November = 11
|
||||
date.December = 12
|
||||
```
|
||||
|
||||
## Date and time functions
|
||||
{{< children type="functions" show="pages" >}}
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.hour() function
|
||||
description: >
|
||||
The `date.hour()` function returns the hour of a specified time.
|
||||
Results range from `[0-23]`.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.hour
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.hour()` function returns the hour of a specified time.
|
||||
Results range from `[0-23]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.hour(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 12
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.minute() function
|
||||
description: >
|
||||
The `date.minute()` function returns the minute of a specified time.
|
||||
Results range from `[0-59]`.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.minute
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.minute()` function returns the minute of a specified time.
|
||||
Results range from `[0-59]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.minute(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 5
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.month() function
|
||||
description: >
|
||||
The `date.month()` function returns the month of a specified time.
|
||||
Results range from `[1-12]`
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.month
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.month()` function returns the month of a specified time.
|
||||
Results range from `[1-12]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.month(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 7
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.monthDay() function
|
||||
description: >
|
||||
The `date.monthDay()` function returns the day of the month for a specified time.
|
||||
Results range from `[1-31]`.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.monthDay
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.monthDay()` function returns the day of the month for a specified time.
|
||||
Results range from `[1-31]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.monthDay(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 17
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.second() function
|
||||
description: >
|
||||
The `date.second()` function returns the second of a specified time.
|
||||
Results range from `[0-59]`.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.second
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.second()` function returns the second of a specified time.
|
||||
Results range from `[0-59]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.second(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 21
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.weekDay() function
|
||||
description: >
|
||||
The `date.weekDay()` function returns the day of the week for a specified time.
|
||||
Results range from `[0-6]`.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.weekDay
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.weekDay()` function returns the day of the week for a specified time.
|
||||
Results range from `[0-6]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.weekDay(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 3
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: date.yearDay() function
|
||||
description: >
|
||||
The `date.yearDay()` function returns the day of the year for a specified time.
|
||||
Results range from `[1-365]` for non-leap years, and `[1-366]` in leap years.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: date.yearDay
|
||||
parent: Date
|
||||
weight: 301
|
||||
---
|
||||
|
||||
The `date.yearDay()` function returns the day of the year for a specified time.
|
||||
Results include leap days and range from `[1-366]`.
|
||||
|
||||
_**Function type:** Transformation_
|
||||
|
||||
```js
|
||||
import "date"
|
||||
|
||||
date.yearDay(t: 2019-07-17T12:05:21.012Z)
|
||||
|
||||
// Returns 198
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### t
|
||||
The time to operate on.
|
||||
|
||||
_**Data type:** Time_
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
title: Built-ins
|
||||
description: >
|
||||
Flux contains many preassigned values.
|
||||
These preassigned values are defined in the source files for the various built-in packages.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Built-ins
|
||||
parent: Flux specification
|
||||
weight: 208
|
||||
---
|
||||
|
||||
Flux contains many preassigned values.
|
||||
These preassigned values are defined in the source files for the various built-in packages.
|
||||
|
||||
{{< children >}}
|
|
@ -1,56 +0,0 @@
|
|||
---
|
||||
title: Time constants
|
||||
description: >
|
||||
Flux provides built-in time constants for days of the week and months of the year.
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: Time constants
|
||||
parent: Built-ins
|
||||
weight: 301
|
||||
---
|
||||
|
||||
{{% note %}}
|
||||
This document is a living document and may not represent the current implementation of Flux.
|
||||
Any section that is not currently implemented is commented with a **[IMPL#XXX]** where
|
||||
**XXX** is an issue number tracking discussion and progress towards implementation.
|
||||
{{% /note %}}
|
||||
|
||||
## Days of the week
|
||||
Days of the week are represented as integers in the range `[0-6]`.
|
||||
The following builtin values are defined:
|
||||
|
||||
```js
|
||||
Sunday = 0
|
||||
Monday = 1
|
||||
Tuesday = 2
|
||||
Wednesday = 3
|
||||
Thursday = 4
|
||||
Friday = 5
|
||||
Saturday = 6
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
[IMPL#153](https://github.com/influxdata/flux/issues/153) Add Days of the Week constants
|
||||
{{% /note %}}
|
||||
|
||||
## Months of the year
|
||||
Months are represented as integers in the range `[1-12]`.
|
||||
The following builtin values are defined:
|
||||
```js
|
||||
January = 1
|
||||
February = 2
|
||||
March = 3
|
||||
April = 4
|
||||
May = 5
|
||||
June = 6
|
||||
July = 7
|
||||
August = 8
|
||||
September = 9
|
||||
October = 10
|
||||
November = 11
|
||||
December = 12
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
[IMPL#154](https://github.com/influxdata/flux/issues/154) Add Months of the Year constants
|
||||
{{% /note %}}
|
|
@ -42,7 +42,7 @@ Object literals construct a value with the object type.
|
|||
```js
|
||||
ObjectLiteral = "{" ObjectBody "}" .
|
||||
ObjectBody = WithProperties | PropertyList .
|
||||
WithProperties = identifier "with" PropertyList .
|
||||
WithProperties = identifier "with" PropertyList .
|
||||
PropertyList = [ Property { "," Property } ] .
|
||||
Property = identifier [ ":" Expression ]
|
||||
| string_lit ":" Expression .
|
||||
|
@ -198,22 +198,23 @@ Operators combine operands into expressions.
|
|||
The precedence of the operators is given in the table below.
|
||||
Operators with a lower number have higher precedence.
|
||||
|
||||
| Precedence | Operator | Description |
|
||||
|:----------:|:--------: |:--------------------------|
|
||||
| 1 | `a()` | Function call |
|
||||
| | `a[]` | Member or index access |
|
||||
| | `.` | Member access |
|
||||
| 2 | `*` `/` |Multiplication and division|
|
||||
| 3 | `+` `-` | Addition and subtraction |
|
||||
| 4 |`==` `!=` | Comparison operators |
|
||||
| | `<` `<=` | |
|
||||
| | `>` `>=` | |
|
||||
| |`=~` `!~` | |
|
||||
| 5 | `not` | Unary logical operator |
|
||||
| | `exists` | Null check operator |
|
||||
| 6 | `and` | Logical AND |
|
||||
| 7 | `or` | Logical OR |
|
||||
| 8 | `if` `then` `else` | Conditional |
|
||||
| Precedence | Operator | Description |
|
||||
|:----------:|:--------: |:-------------------------- |
|
||||
| 1 | `a()` | Function call |
|
||||
| | `a[]` | Member or index access |
|
||||
| | `.` | Member access |
|
||||
| 2 | `^` | Exponentiation |
|
||||
| 3 | `*` `/` `%` | Multiplication, division, and modulo |
|
||||
| 4 | `+` `-` | Addition and subtraction |
|
||||
| 5 |`==` `!=` | Comparison operators |
|
||||
| | `<` `<=` | |
|
||||
| | `>` `>=` | |
|
||||
| |`=~` `!~` | |
|
||||
| 6 | `not` | Unary logical operator |
|
||||
| | `exists` | Null check operator |
|
||||
| 7 | `and` | Logical AND |
|
||||
| 8 | `or` | Logical OR |
|
||||
| 9 | `if` `then` `else` | Conditional |
|
||||
|
||||
The operator precedence is encoded directly into the grammar as the following.
|
||||
|
||||
|
@ -235,7 +236,7 @@ AdditiveExpression = MultiplicativeExpression
|
|||
AdditiveOperator = "+" | "-" .
|
||||
MultiplicativeExpression = PipeExpression
|
||||
| MultiplicativeExpression MultiplicativeOperator PipeExpression .
|
||||
MultiplicativeOperator = "*" | "/" .
|
||||
MultiplicativeOperator = "*" | "/" | "%" | "^".
|
||||
PipeExpression = PostfixExpression
|
||||
| PipeExpression PipeOperator UnaryExpression .
|
||||
PipeOperator = "|>" .
|
||||
|
|
|
@ -34,7 +34,8 @@ perform a calculation that returns a single numerical value.
|
|||
| `-` | Subtraction | `3 - 2` | `1` |
|
||||
| `*` | Multiplication | `2 * 3` | `6` |
|
||||
| `/` | Division | `9 / 3` | `3` |
|
||||
| `%` | Modulus | `10 % 5` | `0` |
|
||||
| `^` | Exponentiation | `2 ^ 3` | `8` |
|
||||
| `%` | Modulo | `10 % 5` | `0` |
|
||||
|
||||
{{% note %}}
|
||||
In the current version of Flux, values used in arithmetic operations must
|
||||
|
|
|
@ -3,11 +3,13 @@ title: System built-ins
|
|||
description: >
|
||||
When a built-in value is not expressible in Flux, its value may be defined by the hosting environment.
|
||||
All such values must have a corresponding builtin statement to declare the existence and type of the built-in value.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/language/built-ins/system-built-ins/
|
||||
menu:
|
||||
v2_0_ref:
|
||||
name: System built-ins
|
||||
parent: Built-ins
|
||||
weight: 301
|
||||
parent: Flux specification
|
||||
weight: 206
|
||||
---
|
||||
|
||||
When a built-in value is not expressible in Flux, its value may be defined by the hosting environment.
|
|
@ -11,11 +11,85 @@ aliases:
|
|||
---
|
||||
|
||||
{{% note %}}
|
||||
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.35.1**.
|
||||
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.37.2**.
|
||||
Though newer versions of Flux may be available, they will not be included with
|
||||
InfluxDB until the next InfluxDB v2.0 release._
|
||||
{{% /note %}}
|
||||
|
||||
---
|
||||
|
||||
## v0.37.2 [2019-07-24]
|
||||
|
||||
- _General cleanup of internal code._
|
||||
|
||||
---
|
||||
|
||||
## v0.37.1 [2019-07-23]
|
||||
|
||||
### Bug fixes
|
||||
- Fixed InfluxDB test errors.
|
||||
- Add range to tests to pass in InfluxDB.
|
||||
|
||||
---
|
||||
|
||||
## v0.37.0 [2019-07-22]
|
||||
|
||||
### Features
|
||||
- Add PromQL to Flux transpiler and Flux helper functions.
|
||||
- Add mutable arrow array builders.
|
||||
- Created date package.
|
||||
- Return query and result errors in the multi result encoder.
|
||||
- Add `exponentialMovingAverage()`.
|
||||
- Add full draft of Rust parser.
|
||||
- Implement more production rules.
|
||||
- AST marshalling.
|
||||
- Parse statements.
|
||||
- Parse integer and float literals.
|
||||
- Add initial Rust implementation of parser.
|
||||
|
||||
---
|
||||
|
||||
## v0.36.2 [2019-07-12]
|
||||
|
||||
### Bug fixes
|
||||
- Add helper methods for comparing entire result sets.
|
||||
- Map will not panic when a record is `null`.
|
||||
|
||||
---
|
||||
|
||||
## v0.36.1 [2019-07-10]
|
||||
|
||||
### Bug fixes
|
||||
- Add `range` call to some end-to-end tests.
|
||||
- Fix implementation of `strings.replaceAll`.
|
||||
|
||||
---
|
||||
|
||||
## v0.36.0 [2019-07-09]
|
||||
|
||||
### Features
|
||||
- Updated `movingAverage()` and added `timedMovingAverage`.
|
||||
- `elapsed()` function.
|
||||
- `mode()` function.
|
||||
- `sleep()` function.
|
||||
- Modify error usage in places to use the new enriched errors.
|
||||
- Enriched error interface.
|
||||
- End-to-end tests that show how to mimic pandas functionality.
|
||||
- End-to-end tests for string functions.
|
||||
|
||||
### Bug fixes
|
||||
- Fix `difference()` so that it returns an error instead of panicking when given a `_time` column.
|
||||
- Added end-to-end tests for type conversion functions.
|
||||
- Make `map()` error if return type is not an object.
|
||||
- Fixed miscounted allocations in the `ColListTableBuilder`.
|
||||
- Support formatting `with`.
|
||||
|
||||
### Breaking changes
|
||||
- Updated `movingAverage()` to `timedMovingAverage` and added new
|
||||
`movingAverage()` implementation.
|
||||
|
||||
---
|
||||
|
||||
## v0.35.1 [2019-07-03]
|
||||
|
||||
### Bug fixes
|
||||
|
|
|
@ -8,6 +8,22 @@ menu:
|
|||
weight: 101
|
||||
---
|
||||
|
||||
## v2.0.0-alpha.16 [2019-07-25]
|
||||
|
||||
### Bug Fixes
|
||||
- Add link to documentation text in line protocol upload overlay.
|
||||
- Fix issue in Authorization API, can't create auth for another user.
|
||||
- Fix Influx CLI ignored user flag for auth creation.
|
||||
- Fix the map example in the documentation.
|
||||
- Ignore null/empty Flux rows which prevents a single stat/gauge crash.
|
||||
- Fixes an issue where clicking on a dashboard name caused an incorrect redirect.
|
||||
- Upgrade templates lib to 0.5.0.
|
||||
- Upgrade giraffe lib to 0.16.1.
|
||||
- Fix incorrect notification type for manually running a task.
|
||||
- Fix an issue where canceled tasks did not resume.
|
||||
|
||||
---
|
||||
|
||||
## v2.0.0-alpha.15 [2019-07-11]
|
||||
|
||||
### Features
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ul>
|
||||
{{ range .Params.related }}
|
||||
{{ if in . "http" }}
|
||||
{{ $link := replaceRE `\,\s(...)*$` "" . }}
|
||||
{{ $link := replaceRE `\,\s(.*)$` "" . }}
|
||||
{{ $title := replaceRE `^(\S*\,\s)` "" . }}
|
||||
<li><a href="{{ $link }}" target="_blank">{{ $title }}</a></li>
|
||||
{{ else }}
|
||||
|
|
Loading…
Reference in New Issue