# 'SHOW SERIES CARDINALITY' in InfluxDB v2

**URL:** <https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554>\
**Category:** InfluxDB 2\
**Tags:** influxql, flux, cardinality\
**Created:** [April 23, 2021, 11:14am UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554 "2021-04-23T11:14:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![0liver](https://avatars.discourse-cdn.com/v4/letter/0/a3d4f5/32.png) [@0liver](https://community.influxdata.com/u/0liver)\
**Post date:** [April 23, 2021, 11:14am UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/1 "2021-04-23T11:14:48Z")

</div>

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](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/influxdb/cardinality/)

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](https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/influxdb-schema/tagvalues/)

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [April 23, 2021, 3:20pm UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/2 "2021-04-23T15:20:26Z")

</div>

@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.

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

```

---

<div class="post-metadata">

**Author:** ![letrout](https://avatars.discourse-cdn.com/v4/letter/l/57b2e6/32.png) [@letrout](https://community.influxdata.com/u/letrout)\
**Post date:** [October 20, 2021, 4:31pm UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/3 "2021-10-20T16:31:59Z")

</div>

this query gives me the error

```auto
unsupported input type for mean aggregate: boolean

```

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [October 21, 2021, 6:02pm UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/4 "2021-10-21T18:02:12Z")

</div>

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:

> **[InfluxDB Tech Tips | Monitoring Tasks & Finding the Source of Cardinality](https://www.influxdata.com/blog/tldr-influxdb-tech-tips-monitoring-tasks-and-finding-the-source-of-runaway-cardinality/)**
>
> Today, well apply the Operational Monitoring Template to our InfluxDB Cloud account to monitor our cardinality and task execution.

and

> **[community-templates/influxdb2\_operational\_monitoring at master ·...](https://github.com/influxdata/community-templates/tree/master/influxdb2_operational_monitoring)**
>
> master/influxdb2\_operational\_monitoring

---

<div class="post-metadata">

**Author:** ![0liver](https://avatars.discourse-cdn.com/v4/letter/0/a3d4f5/32.png) [@0liver](https://community.influxdata.com/u/0liver)\
**Post date:** [October 22, 2021, 8:41am UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/5 "2021-10-22T08:41:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [October 22, 2021, 2:49pm UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/6 "2021-10-22T14:49:27Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![0liver](https://avatars.discourse-cdn.com/v4/letter/0/a3d4f5/32.png) [@0liver](https://community.influxdata.com/u/0liver)\
**Post date:** [October 22, 2021, 3:11pm UTC](https://community.influxdata.com/t/show-series-cardinality-in-influxdb-v2/19554/7 "2021-10-22T15:11:07Z")

</div>

Nice ! Thank you for your update @scott ! 😃
