commit
1194e005df
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
title: length() function
|
||||||
|
description: The `length()` function returns the number of items in an array.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: length
|
||||||
|
parent: built-in-misc
|
||||||
|
weight: 401
|
||||||
|
---
|
||||||
|
|
||||||
|
The `length()` function returns the number of items in an array.
|
||||||
|
|
||||||
|
_**Function type:** Miscellaneous_
|
||||||
|
|
||||||
|
```js
|
||||||
|
length(arr: [])
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### arr
|
||||||
|
The array to evaluate.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
```js
|
||||||
|
people = ["John", "Jane", "Abed"]
|
||||||
|
|
||||||
|
length(arr: people)
|
||||||
|
|
||||||
|
// Returns 3
|
||||||
|
```
|
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
title: Flux Query package
|
||||||
|
list_title: Query package
|
||||||
|
description: >
|
||||||
|
The Flux Query package provides functions meant to simplify common InfluxDB queries.
|
||||||
|
Import the `experimental/query` package.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: Query
|
||||||
|
parent: Experimental
|
||||||
|
weight: 201
|
||||||
|
v2.0/tags: [package]
|
||||||
|
---
|
||||||
|
|
||||||
|
Flux Query functions provide functions meant to simplify common InfluxDB queries.
|
||||||
|
Import the `experimental/query` package:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< children type="functions" show="pages" >}}
|
||||||
|
|
||||||
|
## inBucket()
|
||||||
|
The primary function in this package is [`query.inBucket()`](/v2.0/reference/flux/stdlib/experimental/query/inbucket/),
|
||||||
|
which uses all other functions in this package.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.inBucket(
|
||||||
|
bucket: "example-bucket",
|
||||||
|
start: -1h,
|
||||||
|
stop: now(),
|
||||||
|
measurement: "example-measurement",
|
||||||
|
fields: ["exampleField1", "exampleField2"],
|
||||||
|
predicate: (r) => r.tagA == "foo" and r.tagB != "bar"
|
||||||
|
)
|
||||||
|
```
|
|
@ -0,0 +1,58 @@
|
||||||
|
---
|
||||||
|
title: query.filterFields() function
|
||||||
|
description: >
|
||||||
|
The `query.filterFields()` function filters input data by field.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: query.filterFields
|
||||||
|
parent: Query
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `query.filterFields()` function filters input data by field.
|
||||||
|
|
||||||
|
_**Function type:** Transformation_
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.filterFields(
|
||||||
|
fields: ["exampleField1", "exampleField2"]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### fields
|
||||||
|
Fields to filter by.
|
||||||
|
Must be exact string matches.
|
||||||
|
|
||||||
|
_**Data type:** Array of strings_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.fromRange(bucket: "telegraf", start: -1h)
|
||||||
|
|> query.filterFields(
|
||||||
|
fields: ["used_percent", "available_percent"]
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Function definition
|
||||||
|
```js
|
||||||
|
package query
|
||||||
|
|
||||||
|
filterFields = (tables=<-, fields=[]) =>
|
||||||
|
if length(arr: fields) == 0 then
|
||||||
|
tables
|
||||||
|
else
|
||||||
|
tables
|
||||||
|
|> filter(fn: (r) => contains(value: r._field, set: fields))
|
||||||
|
```
|
||||||
|
|
||||||
|
_**Used functions:**_
|
||||||
|
[contains()](/v2.0/reference/flux/stdlib/built-in/tests/contains/)
|
||||||
|
[filter()](/v2.0/reference/flux/stdlib/built-in/transformations/filter/)
|
||||||
|
[length()](/v2.0/reference/flux/stdlib/built-in/misc/length/)
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
title: query.filterMeasurement() function
|
||||||
|
description: >
|
||||||
|
The `query.filterMeasurement()` function filters input data by measurement.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: query.filterMeasurement
|
||||||
|
parent: Query
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `query.filterMeasurement()` function filters input data by measurement.
|
||||||
|
|
||||||
|
_**Function type:** Transformation_
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.filterMeasurement(
|
||||||
|
measurement: "example-measurement"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### measurement
|
||||||
|
The name of the measurement to filter by.
|
||||||
|
Must be an exact string match.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.fromRange(bucket: "example-bucket", start: -1h)
|
||||||
|
|> query.filterMeasurement(
|
||||||
|
measurement: "example-measurement"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Function definition
|
||||||
|
```js
|
||||||
|
package query
|
||||||
|
|
||||||
|
filterMeasurement = (tables=<-, measurement) =>
|
||||||
|
tables
|
||||||
|
|> filter(fn: (r) => r._measurement == measurement)
|
||||||
|
```
|
||||||
|
|
||||||
|
_**Used functions:**_
|
||||||
|
[filter()](/v2.0/reference/flux/stdlib/built-in/transformations/filter/)
|
|
@ -0,0 +1,76 @@
|
||||||
|
---
|
||||||
|
title: query.fromRange() function
|
||||||
|
description: >
|
||||||
|
The `query.fromRange()` function returns all data from a specified bucket within
|
||||||
|
given time bounds.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: query.fromRange
|
||||||
|
parent: Query
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `query.fromRange()` function returns all data from a specified bucket within
|
||||||
|
given time bounds.
|
||||||
|
|
||||||
|
_**Function type:** Input_
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.fromRange(
|
||||||
|
bucket: "example-bucket",
|
||||||
|
start: -1h,
|
||||||
|
stop: now()
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### bucket
|
||||||
|
The name of the bucket to query.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### start
|
||||||
|
The earliest time to include in results.
|
||||||
|
Results **include** points that match the specified start time.
|
||||||
|
Use a relative duration or absolute time.
|
||||||
|
For example, `-1h` or `2019-08-28T22:00:00Z`.
|
||||||
|
Durations are relative to `now()`.
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
### stop
|
||||||
|
The latest time to include in results.
|
||||||
|
Results **exclude** points that match the specified stop time.
|
||||||
|
Use a relative duration or absolute time.
|
||||||
|
For example, `-1h` or `2019-08-28T22:00:00Z`.
|
||||||
|
Durations are relative to `now()`.
|
||||||
|
Defaults to `now()`.
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.fromRange(
|
||||||
|
bucket: "example-bucket",
|
||||||
|
start: 2020-01-01T00:00:00Z
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Function definition
|
||||||
|
```js
|
||||||
|
package query
|
||||||
|
|
||||||
|
fromRange = (bucket, start, stop=now()) =>
|
||||||
|
from(bucket: bucket)
|
||||||
|
|> range(start: start, stop: stop)
|
||||||
|
```
|
||||||
|
|
||||||
|
_**Used functions:**_
|
||||||
|
[from()](/v2.0/reference/flux/stdlib/built-in/inputs/from/)
|
||||||
|
[range()](/v2.0/reference/flux/stdlib/built-in/transformations/range/)
|
|
@ -0,0 +1,115 @@
|
||||||
|
---
|
||||||
|
title: query.inBucket() function
|
||||||
|
description: >
|
||||||
|
The `query.inBucket()` function queries data from a specified bucket within given
|
||||||
|
time bounds, filters data by measurement, field, and optional predicate expressions.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: query.inBucket
|
||||||
|
parent: Query
|
||||||
|
weight: 301
|
||||||
|
---
|
||||||
|
|
||||||
|
The `query.inBucket()` function queries data from a specified bucket within given
|
||||||
|
time bounds, filters data by measurement, field, and optional predicate expressions.
|
||||||
|
|
||||||
|
_**Function type:** Input_
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.inBucket(
|
||||||
|
bucket: "example-bucket",
|
||||||
|
start: -1h,
|
||||||
|
stop: now(),
|
||||||
|
measurement: "example-measurement",
|
||||||
|
fields: ["exampleField1", "exampleField2"],
|
||||||
|
predicate: (r) => true
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### bucket
|
||||||
|
The name of the bucket to query.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### start
|
||||||
|
The earliest time to include in results.
|
||||||
|
Results **include** points that match the specified start time.
|
||||||
|
Use a relative duration or absolute time.
|
||||||
|
For example, `-1h` or `2019-08-28T22:00:00Z`.
|
||||||
|
Durations are relative to `now()`.
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
### stop
|
||||||
|
The latest time to include in results.
|
||||||
|
Results **exclude** points that match the specified stop time.
|
||||||
|
Use a relative duration or absolute time.
|
||||||
|
For example, `-1h` or `2019-08-28T22:00:00Z`.
|
||||||
|
Durations are relative to `now()`.
|
||||||
|
Defaults to `now()`.
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
### measurement
|
||||||
|
The name of the measurement to filter by.
|
||||||
|
Must be an exact string match.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### fields
|
||||||
|
Fields to filter by.
|
||||||
|
Must be exact string matches.
|
||||||
|
|
||||||
|
_**Data type:** Array of strings_
|
||||||
|
|
||||||
|
### predicate
|
||||||
|
A single argument function that evaluates true or false.
|
||||||
|
Records are passed to the function.
|
||||||
|
Those that evaluate to `true` are included in the output tables.
|
||||||
|
Records that evaluate to `null` or `false` are not included in the output tables.
|
||||||
|
Default is `(r) => true`.
|
||||||
|
|
||||||
|
_**Data type:** Function_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
##### Query memory data from host1
|
||||||
|
```js
|
||||||
|
import "experimental/query"
|
||||||
|
|
||||||
|
query.inBucket(
|
||||||
|
bucket: "telegraf",
|
||||||
|
start: -1h,
|
||||||
|
measurement: "mem",
|
||||||
|
fields: ["used_percent", "available_percent"],
|
||||||
|
predicate: (r) => r.host == "host1"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Function definition
|
||||||
|
```js
|
||||||
|
package query
|
||||||
|
|
||||||
|
inBucket = (
|
||||||
|
bucket,
|
||||||
|
start,
|
||||||
|
stop=now(),
|
||||||
|
measurement,
|
||||||
|
fields=[],
|
||||||
|
predicate=(r) => true
|
||||||
|
) =>
|
||||||
|
fromRange(bucket: bucket, start: start, stop: stop)
|
||||||
|
|> filterMeasurement(measurement)
|
||||||
|
|> filter(fn: predicate)
|
||||||
|
|> filterFields(fields)
|
||||||
|
```
|
||||||
|
|
||||||
|
_**Used functions:**_
|
||||||
|
[filter()](/v2.0/reference/flux/stdlib/built-in/transformations/filter/)
|
||||||
|
[query.filterFields()](/v2.0/reference/flux/stdlib/experimental/query/filterfields/)
|
||||||
|
[query.filterMeasurement()](/v2.0/reference/flux/stdlib/experimental/query/filtermeasurement/)
|
||||||
|
[query.fromRange()](/v2.0/reference/flux/stdlib/experimental/query/fromrange/)
|
|
@ -16,6 +16,34 @@ Though newer versions of Flux may be available, they will not be included with
|
||||||
InfluxDB until the next InfluxDB v2.0 release._
|
InfluxDB until the next InfluxDB v2.0 release._
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
|
## v0.60.0 [2020-02-19]
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add experimental `query` package.
|
||||||
|
- Create a Docker environment for Flux releases.
|
||||||
|
- Validate there are no free type variables in prelude/stdlib build.
|
||||||
|
- Add formatter library.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- `derivative()` works properly across multiple buffers.
|
||||||
|
- Fix free type variable found in `tripleExponentialDerivative()`.
|
||||||
|
- Update type of `window()` function.
|
||||||
|
- Freshen row types using deterministic property order.
|
||||||
|
- Libflux JSON deserialization uses type properly.
|
||||||
|
- Expose the builtin polytypes when analyzing a `stdlib` package.
|
||||||
|
- Deserialize call expressions when arguments are missing.
|
||||||
|
- Handled malformed data as well as EOF.
|
||||||
|
- Allow unsigned integers to be subtractable.
|
||||||
|
- Link both `libflux` and `liblibstd` for flux-config.
|
||||||
|
- Link `libstd` into the `lib` directory instead of `libflux`.
|
||||||
|
- Flux-config correctly copies `stdlib` when using a module.
|
||||||
|
- Add 169.254/16 range to URL validator.
|
||||||
|
- Update `uuid` library to improve security.
|
||||||
|
- Handle invalid string literals.
|
||||||
|
- Remove 'tags' line from local tags.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v0.59.6 [2020-02-13]
|
## v0.59.6 [2020-02-13]
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="warn block">
|
<div class="warn block">
|
||||||
<p>
|
<p>
|
||||||
The {{ if $.Params.list_title }}{{ $.Params.list_title }}{{ else }}{{ .Title }}{{ end }} is experimental and subject to change at any time.
|
The {{ if $.Params.list_title }}{{ $.Params.list_title }}{{ else }}{{ .Title }}{{ end }} is experimental and subject to change at any time.
|
||||||
By using this function, you accept the <a href="{{ $expRiskURL }}">risks of experimental functions</a>.
|
By using this package, you accept the <a href="{{ $expRiskURL }}">risks of experimental functions</a>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue