Documentation

influxdb.cardinality() function

Flux 0.92.0+

The influxdb.cardinality() function returns the series cardinality of data stored in InfluxDB Cloud.

InfluxDB Cloud supports the influxdb.cardinality() function, but InfluxDB OSS does not.

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.

bucketID

String-encoded bucket ID to query cardinality from.

org

Organization name.

orgID

String-encoded organization ID to query cardinality from.

host

URL of the InfluxDB instance to query. See InfluxDB Cloud regions or InfluxDB OSS URLs.

token

InfluxDB API token.

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().

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(). Default is now().

predicate

Predicate function that filters records. Default is (r) => true.

Examples

Query series cardinality in a bucket
import "influxdata/influxdb"

influxdb.cardinality(
  bucket: "example-bucket",
  start: -1y
)
Query series cardinality in a measurement
import "influxdata/influxdb"

influxdb.cardinality(
  bucket: "example-bucket",
  start: -1y,
  predicate: (r) => r._measurement == "example-measurement"
)
Query series cardinality for a specific tag
import "influxdata/influxdb"

influxdb.cardinality(
  bucket: "example-bucket",
  start: -1y,
  predicate: (r) => r.exampleTag == "foo"
)

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.