influxdbinfluxqlflux-influxdb

Get tag values for a specific time and measurement in InfluxQL


I have an Influx DB with a database database1 containing a measurement positions that looks like this:

time                   serie        machine      position
-------------       -----------   -----------   ----------
1645494054000000000      0          uther           59       
1645494055000000000      0          lascr           58
1645494056000000000      1          lascr           46

position is my field and I have two tags serie and machine.

How can I retrieve all distinct values for the tag serie in a given time interval ? Here, I would like the output to be [0] for input times 1645494054000000000 and 1645494055000000000 (lower and upper bound) and [0, 1] for input times 1645494054000000000 and 1645494056000000000.

I have tried to use SHOW TAG VALUES but it can only filter on other tag values and not on time.

The only solution I have found for now is to use a subquery like this:

SELECT DISTINCT("serie") FROM (SELECT position,serie FROM positions WHERE time >= 1645494054000000000 AND time <= 1645494056000000000)

to get this:

name: positions
time distinct
---- --------
0    0
0    1

which is what I want, but seems overly complicated.


Solution

  • The only answer I have found is in fact the one mentioned in my question:

    SELECT DISTINCT("serie") FROM (SELECT position,serie FROM positions WHERE time >= 1645494054000000000 AND time <= 1645494056000000000)