Documentation

influxdb.cardinality() function

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

Function type signature
(
    start: A,
    ?bucket: string,
    ?bucketID: string,
    ?host: string,
    ?org: string,
    ?orgID: string,
    ?predicate: (r: {B with _value: C, _measurement: string, _field: string}) => bool,
    ?stop: D,
    ?token: string,
) => stream[{_value: int, _stop: time, _start: time}] where A: Timeable, D: Timeable
For more information, see Function type signatures.

Parameters

bucket

Bucket to query cardinality from.

bucketID

String-encoded bucket ID to query cardinality from.

org

Organization name.

orgID

String-encoded organization ID.

host

URL of the InfluxDB instance to query.

See InfluxDB Cloud regions or InfluxDB OSS URLs.

token

InfluxDB API token.

start

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

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

Was this page helpful?

Thank you for your feedback!


Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.

State of the InfluxDB Cloud (IOx) documentation

The new documentation for InfluxDB Cloud backed by InfluxDB IOx is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.