Paul Johnson
Paul Johnson

Reputation: 41

How do I obtain a list of Tags from an InfluxDB Database

we are currently looking at migrating our company data historian over to InfluxDB. We have a Tag called 'tagname' and I would like to run a query to return a list of tagnames, how do I do this? Is this even possible? I have tried the following which seems logical to me coming from a SQL background however all this returns is an empty set:

q=SELECT "tagname" FROM "companyname"."autogen"."lvdata"

'companyname' is a placeholder for actual schema content.

I then tried to look for the last value of each tagname:

q=SELECT "tagname", LAST("value") FROM "companyname"."autogen"."lvdata" WHERE TIME >= '1970-01-01 00:00:00' AND time < '2023-08-14 00:00:00'

but this just returned a single value:

name,tags,time,tagname,last lvdata,,1672271400000000000,tagname,248.564

Kind Regards Paul.

Upvotes: 0

Views: 669

Answers (1)

alespour
alespour

Reputation: 465

There are schema exploring queries that might be better for this, like SHOW TAG VALUES, eg:

SHOW TAG VALUES ON companyname WITH KEY = "tagname"

But I'd expect your query to work as well.

Upvotes: 0

Related Questions