Return tag keys with query


I am trying to create a dashboard which returns only the top 10 systems for a performance dashboard, but I can’t seem to get the output I am looking for.

Right now the query looks like this:
SELECT top(“iops”, 10) FROM “lun” WHERE $timeFilter GROUP BY time(1h), “name”

But this doesn’t return top 10, instead it returns all the data points and ignores the group by time filter.

Is there a way to do this?

I think it is necessary to select time also, so possibly
select time,top...

I added time to the select statement, though it appears to have the same result:

I think this may have some clues on how to to it

I think I’m misunderstanding how the query is working.

When I run the query manually in influx, the statement:

SELECT top(“iops”, 2) FROM “lun” GROUP by “name”

returns a “top” value for every tag key based on a 5 minute interval. Even if I group by any other time interval, it returns a 5 minute interval. I’ll play around a bit more to see if I can figure this out.

Think I sorted it out. The article you provided was helpful.

SELECT top(“max”,“name”,10) as “PEAK IOPS” FROM (SELECT max(“iops”) FROM “lun” GROUP by “name”) WHERE time > now() - 24h

The “second” select returns the maximum IOPS values for each tag key which is then used by the “first” select to find the top 10 values of that query. Important note is that the quotes around “max” and “name” are required.