Flux 0.93 (#1760)
* added flux-0.92 and cardinality function * added flux 0.93 release notes * removed unsupported types from cardinality params * updated cardinality function to address PR feedbackpull/1762/head
parent
2dc0bf1c44
commit
91a0c750c0
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
title: Flux InfluxDB package
|
||||||
|
list_title: InfluxDB package
|
||||||
|
description: >
|
||||||
|
The Flux InfluxDB package provides functions for analyzing InfluxDB metadata.
|
||||||
|
Import the `influxdata/influxdb` package.
|
||||||
|
menu:
|
||||||
|
influxdb_2_0_ref:
|
||||||
|
name: InfluxDB
|
||||||
|
identifier: influxdb-pkg
|
||||||
|
parent: Flux standard library
|
||||||
|
weight: 202
|
||||||
|
influxdb/v2.0/tags: [functions, package]
|
||||||
|
introduced: 0.92.0
|
||||||
|
---
|
||||||
|
|
||||||
|
The Flux InfluxDB package provides functions for analyzing InfluxDB metadata.
|
||||||
|
Import the `influxdata/influxdb` package:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "influxdata/influxdb"
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< children type="functions" show="pages" >}}
|
|
@ -0,0 +1,137 @@
|
||||||
|
---
|
||||||
|
title: influxdb.cardinality() function
|
||||||
|
description: The `influxdb.cardinality()` function returns the series cardinality of data stored in InfluxDB Cloud.
|
||||||
|
menu:
|
||||||
|
influxdb_2_0_ref:
|
||||||
|
name: influxdb.cardinality
|
||||||
|
parent: influxdb-pkg
|
||||||
|
weight: 301
|
||||||
|
influxdb/v2.0/tags: [cardinality]
|
||||||
|
related:
|
||||||
|
- /{{< latest "influxdb" "v1" >}}/query_language/spec/#show-cardinality, SHOW CARDINALITY in InfluxQL
|
||||||
|
introduced: 0.92.0
|
||||||
|
---
|
||||||
|
|
||||||
|
The `influxdb.cardinality()` function returns the [series cardinality](/{{< latest "influxdb" "v2" >}}/reference/glossary#series-cardinality) of data stored in InfluxDB Cloud.
|
||||||
|
|
||||||
|
{{% cloud %}}
|
||||||
|
**InfluxDB Cloud** supports the `influxdb.cardinality()` function, but **InfluxDB OSS does not**.
|
||||||
|
{{% /cloud %}}
|
||||||
|
|
||||||
|
```js
|
||||||
|
import "influxdata/influxdb"
|
||||||
|
|
||||||
|
influxdb.cardinality(
|
||||||
|
bucket: "example-bucket",
|
||||||
|
org: "example-org",
|
||||||
|
host: "https://cloud2.influxdata.com",
|
||||||
|
token: "MySuP3rSecr3Tt0k3n",
|
||||||
|
start: -30d,
|
||||||
|
stop: now(),
|
||||||
|
predicate: (r) => true
|
||||||
|
)
|
||||||
|
|
||||||
|
// OR
|
||||||
|
|
||||||
|
influxdb.cardinality(
|
||||||
|
bucketID: "00xXx0x00xXX0000",
|
||||||
|
orgID: "00xXx0x00xXX0000",
|
||||||
|
host: "https://cloud2.influxdata.com",
|
||||||
|
token: "MySuP3rSecr3Tt0k3n",
|
||||||
|
start: -30d,
|
||||||
|
stop: now(),
|
||||||
|
predicate: (r) => true
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### bucket
|
||||||
|
Bucket to query cardinality from.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### bucketID
|
||||||
|
String-encoded bucket ID to query cardinality from.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### org
|
||||||
|
Organization name.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### orgID
|
||||||
|
String-encoded [organization ID](/influxdb/v2.0/organizations/view-orgs/#view-your-organization-id) to query cardinality from.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### host
|
||||||
|
URL of the InfluxDB instance to query.
|
||||||
|
_See [InfluxDB URLs](/influxdb/v2.0/reference/urls/)._
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### token
|
||||||
|
InfluxDB [authentication token](/{{< latest "influxdb" "v2" >}}/security/tokens/).
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### start
|
||||||
|
The earliest time to include when calculating cardinality.
|
||||||
|
The cardinality calculation **includes** 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()`](/influxdb/v2.0/reference/flux/stdlib/built-in/misc/now/).
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
### stop
|
||||||
|
The latest time to include when calculating cardinality.
|
||||||
|
The cardinality calculation **excludes** 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()`](/influxdb/v2.0/reference/flux/stdlib/built-in/misc/now/).
|
||||||
|
Defaults to `now()`.
|
||||||
|
|
||||||
|
_**Data type:** Duration | Time_
|
||||||
|
|
||||||
|
### predicate
|
||||||
|
Predicate function that filters records.
|
||||||
|
_Defaults to `(r) => true`._
|
||||||
|
|
||||||
|
_**Data type:** Function_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
##### Query series cardinality in a bucket
|
||||||
|
```js
|
||||||
|
import "influxdata/influxdb"
|
||||||
|
|
||||||
|
influxdb.cardinality(
|
||||||
|
bucket: "example-bucket"
|
||||||
|
start: -1y,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Query series cardinality in a measurement
|
||||||
|
```js
|
||||||
|
import "influxdata/influxdb"
|
||||||
|
|
||||||
|
influxdb.cardinality(
|
||||||
|
bucket: "example-bucket"
|
||||||
|
start: -1y,
|
||||||
|
predicate: (r) => r._measurement == "example-measurement"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Query series cardinality for a specific tag
|
||||||
|
```js
|
||||||
|
import "influxdata/influxdb"
|
||||||
|
|
||||||
|
influxdb.cardinality(
|
||||||
|
bucket: "example-bucket"
|
||||||
|
start: -1y,
|
||||||
|
predicate: (r) => r.exampleTag == "foo"
|
||||||
|
)
|
||||||
|
```
|
|
@ -825,13 +825,13 @@ Related entries: [field set](#field-set), [measurement](#measurement),<!-- [rete
|
||||||
|
|
||||||
### series cardinality
|
### series cardinality
|
||||||
|
|
||||||
The number of unique bucket, measurement, tag set, and field key combinations in an InfluxDB instance.
|
The number of unique measurement, tag set, and field key combinations in an InfluxDB bucket.
|
||||||
|
|
||||||
For example, assume that an InfluxDB instance has a single bucket and one measurement.
|
For example, assume that an InfluxDB bucket has one measurement.
|
||||||
The single measurement has two tag keys: `email` and `status`.
|
The single measurement has two tag keys: `email` and `status`.
|
||||||
If there are three different `email`s, and each email address is associated with two
|
If there are three different `email`s, and each email address is associated with two
|
||||||
different `status`es, the series cardinality for the measurement is 6
|
different `status`es, the series cardinality for the measurement is 6
|
||||||
(3 * 2 = 6):
|
(3 × 2 = 6):
|
||||||
|
|
||||||
| email | status |
|
| email | status |
|
||||||
| :-------------------- | :----- |
|
| :-------------------- | :----- |
|
||||||
|
@ -842,11 +842,11 @@ different `status`es, the series cardinality for the measurement is 6
|
||||||
| cliff@influxdata.com | start |
|
| cliff@influxdata.com | start |
|
||||||
| cliff@influxdata.com | finish |
|
| cliff@influxdata.com | finish |
|
||||||
|
|
||||||
In some cases, performing this multiplication may overestimate series cardinality because of the presence of dependent tags.
|
In some cases, performing this multiplication may overestimate series cardinality
|
||||||
Dependent tags are scoped by another tag and do not increase series
|
because of the presence of dependent tags.
|
||||||
cardinality.
|
Dependent tags are scoped by another tag and do not increase series cardinality.
|
||||||
If we add the tag `firstname` to the example above, the series cardinality
|
If we add the tag `firstname` to the example above, the series cardinality
|
||||||
would not be 18 (3 * 2 * 3 = 18).
|
would not be 18 (3 × 2 × 3 = 18).
|
||||||
The series cardinality would remain unchanged at 6, as `firstname` is already scoped by the `email` tag:
|
The series cardinality would remain unchanged at 6, as `firstname` is already scoped by the `email` tag:
|
||||||
|
|
||||||
| email | status | firstname |
|
| email | status | firstname |
|
||||||
|
@ -858,7 +858,9 @@ The series cardinality would remain unchanged at 6, as `firstname` is already sc
|
||||||
| cliff@influxdata.com | start | clifford |
|
| cliff@influxdata.com | start | clifford |
|
||||||
| cliff@influxdata.com | finish | clifford |
|
| cliff@influxdata.com | finish | clifford |
|
||||||
|
|
||||||
<!--See [SHOW CARDINALITY](/{{< latest "influxdb" "v1" >}}/query_language/spec/#show-cardinality) to learn about the InfluxQL commands for series cardinality. -->
|
##### Query for cardinality:
|
||||||
|
- **Flux:** [influxdb.cardinality()](/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality/)
|
||||||
|
- **InfluxQL:** [SHOW CARDINALITY](/{{< latest "influxdb" "v1" >}}/query_language/spec/#show-cardinality)
|
||||||
|
|
||||||
Related entries: [field key](#field-key),[measurement](#measurement), [tag key](#tag-key), [tag set](#tag-set)
|
Related entries: [field key](#field-key),[measurement](#measurement), [tag key](#tag-key), [tag set](#tag-set)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,28 @@ menu:
|
||||||
name: Flux
|
name: Flux
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## v0.93.0 [2020-11-02]
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Ensure query plan nodes have unique IDs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v0.92.0 [2020-10-30]
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add `fluxinit` package as an alternative to importing `builtin`.
|
||||||
|
- Add [series `cardinality()` function](/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality/) to InfluxDB package.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- Do not panic when the value column for `pivot()` does not exist.
|
||||||
|
- Properly truncate timestamps to beginning of window bounds.
|
||||||
|
- Updates operator precedence in formatter.
|
||||||
|
- Do not panic when a string expression evaluates to _null_.
|
||||||
|
- Add support for multiline conditional logic.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v0.91.0 [2020-10-26]
|
## v0.91.0 [2020-10-26]
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
Loading…
Reference in New Issue