diff --git a/content/influxdb/v2.0/reference/flux/stdlib/influxdb/_index.md b/content/influxdb/v2.0/reference/flux/stdlib/influxdb/_index.md new file mode 100644 index 000000000..58ad10eff --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/influxdb/_index.md @@ -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" >}} \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality.md b/content/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality.md new file mode 100644 index 000000000..9592775ba --- /dev/null +++ b/content/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality.md @@ -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" +) +``` \ No newline at end of file diff --git a/content/influxdb/v2.0/reference/glossary.md b/content/influxdb/v2.0/reference/glossary.md index 33e8ad62e..d4095ef07 100644 --- a/content/influxdb/v2.0/reference/glossary.md +++ b/content/influxdb/v2.0/reference/glossary.md @@ -825,13 +825,13 @@ Related entries: [field set](#field-set), [measurement](#measurement), +##### 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) diff --git a/content/influxdb/v2.0/reference/release-notes/flux.md b/content/influxdb/v2.0/reference/release-notes/flux.md index b046d313f..4990774b6 100644 --- a/content/influxdb/v2.0/reference/release-notes/flux.md +++ b/content/influxdb/v2.0/reference/release-notes/flux.md @@ -8,6 +8,28 @@ menu: 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] ### Features