Create TopN report for interface errors - grafana

Hi, appreciate this question has kind of been asked previously but I’m still unable to produce the required report. We have many 1000’s of network interfaces being polled by telegraf and counters being stored in influxdb (InfluxDB shell version: 0.13.0).

Database looks something like:

select * from ifStats where time > now() - 5m
name: ifStats

time hostname ifHCInMulticastPkts ifHCInOctets ifHCInUcastPkts ifHCOutMulticastPkts ifHCOutOctets ifHCOutUcastPkts ifInDiscards ifInErrors ifOutDiscards ifOutErrors ifname
2020-04-06T11:56:08Z aq01a.hwy01.loc 15910068460 8614392872293 36430025580 10617396424 15214886326960 37165702158 0 0 0 0 Et49

I’ve got as far as:

SELECT non_negative_derivative(TOP(mean(“ifInErrors”), 10), 1s) FROM “ifStats” WHERE time > now - 1h GROUP BY “hostname”, “ifname” fill(null)

…which I know is wrong!

Specific questions are:

  1. Presumably influx has to calculate ifInErrors for all interfaces to return the TopN - is there the potential for performance issues with this type of query?

  2. Would I be better off investing my time into upgrading to influx 2.0 before working on this type of report?

Thanks all,