'SHOW SERIES CARDINALITY' in InfluxDB v2

Hi,

Just making sure I am not missing anything.

In InfluxDB v1 we used to rely on the SHOW SERIES CARDINALITY.
The same query does not seem to be implemented in v2 and I have found: influxdb.cardinality() function | Flux 0.x Documentation

That seems to be limited to InfluxDB Cloud version only. Is there something available in InfluxDB OSS v2.0.4 for that purpose ?

Or would I need to implement this using the following: schema.tagValues() function | Flux 0.x Documentation

Thanks in advance,

@0liver The influxdb.cardinality() function depends on an API that hasn’t been added to InfluxDB 2.0 yet. In the mean time, you can use a query similar to the following to return the total series cardinality within a time range. Fair warning, this could be a fairly heavy query depending on your data.

By default, from() returns results grouped by series (measurement, tag set, and field key). The example below uses first() to limit each table (series) to a single row, and then group() to group all rows into a single table, and then count() to count the number of rows in the table. That should give you series cardinality.

from(bucket: "example-bucket")
  |> range(start: -1y)
  |> first()
  |> group()
  |> count()
1 Like

this query gives me the error

unsupported input type for mean aggregate: boolean

Hello @letrout,
Can you share the data you’re using? as well as the flux? There isn’t a mean() function in the flux above so I’m surprised that you’re getting that error.

Finally are you using Cloud? If so, you might be interested in:

and

Hi @letrout,

I actually remember I had to use a transform to make it work for me. Apologies, I did not posted the updated query. I will try to retrieve it for you.

To be honest, it did not work for me as suggested by @scott, the query seems to be quite resource intensive and would never return in my case (I believe after 5mn it was still running).

I wish this feature was implemented for OSS v2 as it is something we are highly relying on.

@0liver Just to follow up on this, InfluxDB 2.1 will ship with the API necessary for the influxdb.cardinality() function. It should be available in the next couple of days. You could also build InfluxDB from source if you want it now.

Nice ! Thank you for your update @scott ! :smiley: