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.

  1. import "influxdata/influxdb"
  2. influxdb.cardinality(
  3. bucket: "example-bucket",
  4. org: "example-org",
  5. host: "https://cloud2.influxdata.com",
  6. token: "MySuP3rSecr3Tt0k3n",
  7. start: -30d,
  8. stop: now(),
  9. predicate: (r) => true
  10. )
  11. // OR
  12. influxdb.cardinality(
  13. bucketID: "00xXx0x00xXX0000",
  14. orgID: "00xXx0x00xXX0000",
  15. host: "https://cloud2.influxdata.com",
  16. token: "MySuP3rSecr3Tt0k3n",
  17. start: -30d,
  18. stop: now(),
  19. predicate: (r) => true
  20. )

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
  1. import "influxdata/influxdb"
  2. influxdb.cardinality(
  3. bucket: "example-bucket"
  4. start: -1y,
  5. )
Query series cardinality in a measurement
  1. import "influxdata/influxdb"
  2. influxdb.cardinality(
  3. bucket: "example-bucket"
  4. start: -1y,
  5. predicate: (r) => r._measurement == "example-measurement"
  6. )
Query series cardinality for a specific tag
  1. import "influxdata/influxdb"
  2. influxdb.cardinality(
  3. bucket: "example-bucket"
  4. start: -1y,
  5. predicate: (r) => r.exampleTag == "foo"
  6. )

Related articles

cardinality