Influxdb: [feature request] Count of different tag values

Created on 20 Aug 2015  路  28Comments  路  Source: influxdata/influxdb

Hi together,

with the query

SHOW TAG VALUES WITH KEY = id 

I get a list of all different tag values of my database.

Now I need to count them. An example, there query above returns:

name:idTagValues
----------------------- 
id
myId1
myId2
myId3

I need the result "3". Is their any way to get it? I tried some possibilities but everything fails:
An idea for further releases is to combine two queries, so the second one references at the first query's result:

SHOW TAG VALUES WITH KEY = id; SELECT count(id) FROM idTagValues

Any idea to realize my request?

Thanks :-)

kinfeature-request

Most helpful comment

It seems that update is on the way but I found this nested query:

SELECT count("count") FROM (SELECT count(temperature) FROM mydb GROUP BY sensor)

where sensor is a tag I want to count and temperature is float value associated with the tag.

It looks weird but it works :laughing:

All 28 comments

There's no way to do this currently.

Maybe an idea for further release? I would love to see that I can reference to a query result from an other query.

@The-Nik yes, I changed this to a feature request and left it open so we can discuss whether and when to implement this feature.

This would be useful for us too +1

+1 for us also. The only "workaround" is to store data as a tag and field. Seems wasteful.

+1 would help us a lot

I need this too

+1

+1.

+1

+1

+1

+1

+1

+1

+1

+1

+1

+100

+1

+1

+1

We're going to implement this with #7195.

It seems that update is on the way but I found this nested query:

SELECT count("count") FROM (SELECT count(temperature) FROM mydb GROUP BY sensor)

where sensor is a tag I want to count and temperature is float value associated with the tag.

It looks weird but it works :laughing:

#8636 SHOW CARDINALITY functionality is coming.

@benbjohnson #8636 looks like merged (on Aug 16 itself) , but on latest stable release v1.3.7 [2017-10-26]
SHOW TAG VALUES CARDINALITY FROM "<measurement>" WITH KEY = '<tag key>' or SHOW TAG KEY CARDINALITY is not working. e.g. later gives me error error parsing query: found KEY, expected KEYS, VALUES at line 1, char 10

SHOW CARDINALITY is available starting with the v1.4 release.

I know the issue has been closed, but I find it useful to share a link and example since this page still appears on google search.

This solves the question: https://docs.influxdata.com/influxdb/v1.8/query_language/spec/#show-cardinality

Example in my case:

SHOW TAG VALUES CARDINALITY WITH KEY = "Client_Name"
name: Vodafone_Backups_All_Dashboard
count
........
6062

Was this page helpful?
0 / 5 - 0 ratings