Documentation

influxdb.cardinality() function

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.

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 to query cardinality from.

Data type: String

host

URL of the InfluxDB instance to query. See InfluxDB URLs.

Data type: String

token

InfluxDB authentication token.

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

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

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: