Plot top-X from dynamic set of series

I have a series with a few hundred different tag values in Influxdb. How would I tell Grafana to plot the top-3 only? Where top could be calculated on the last sample.

I can find the top() values, but only for a single time value, like this:

select top(value, 3), tld from (select last(value) as value, tld from tld_counter group by tld)

X-posted at

Unlike some other time series databases, InfluxDB does not support series filter (that I know of). So you will have to wait for InfluxDB to implement this

And by series filter i mean sorting series list based on criteria and only taking top x

Is it possible to use slimit and order by to get the top-3? LIMIT and SLIMIT were added in the recent v4.3.0 beta.

Indeed InfluxDB does not sort on anything but time (in that case I believe SLIMIT would do what we’re looking for).
But today, top() does the trick anyway. I have a point for each user every interval, like

usage,user=xyz cpu=99,mem=99

An InfluxDB query does that with

select top(cpu,3),user from usage where time > now() - 30m 

But I can’t see how to convince Grafana to use the user from the fields rather than from multiple result sets like you get with GROUP BY.


InfluxDB query language does not support this :frowning: