Error in InfluxDB OSS Task of Series Cardinality


I am trying to generate a task that calculates the series cardinality on InfluxdB OSS. The same is running on other InfluxDB instances that I am using but failing for this particular instance.

import “influxdata/influxdb”
option task = {
name: “Series cardinality”,
every: 1d,
dest_bucket = “Cardinality”
dest_measurement = “series_cardinality”
organization = " ****"
bucketCardinality = (bucket) =>
(influxdb.cardinality(bucket: bucket, start: time(v: 0))
|> findColumn(fn: (key) => true, column: "value"))[0]
|> filter(fn: (r) => not =~ /^
|> map(fn: (r) => ({bucket:, “Total_Cardinality”: bucketCardinality(bucket:}))
|> sum(column: “Total_Cardinality”)
|> set(key: “_time”, value: string(v: now()))
|> map(
fn: (r) =>
_value: r.Total_Cardinality,
_measurement: dest_measurement,
_field: “series_cardinality”,
_time: time(v: r._time),
|> to(bucket: dest_bucket, org: organization, timeColumn: “_time”)

The error I am getting is pasted below:

Kindly suggest what changes need to be made here.

Hi @khushipurvesh.jain,
Can you check the InfluxDB instance version compared to the rest? I believe we implemented a fix for non-compatibility with the cardinality function. Great function! If you also wanted something quick and easy I would also recommend checking out this template:

The cardinality now template is the one you would want to use.

Hey, that looks like a great template to use. I have installed the template but the task created by it also shows the same error.
Could you help me with any fix?

Could you let me know which version of InfluxDB2.X you have installed on that instance? You have an interesting error that I have not seen on the latest build.


Its InfluxDB Version 2.0.4 OSS

Hi @khushipurvesh.jain,
I have tried this on the latest version 2.2. I would try updating and see if that fixes the issue.