根据 InfluxDB 中的以下测量结果,我想在 Grafana 中显示一个表格,其中包含给定传感器最常出现的设备的前 2 个结果。 因此,以下数据的预期结果将是一个包含 2 条数据的表格
device total ------ ---- 345678 7 234567 3
> select * from incoming_events_by_device limit 50; name: incoming_events_by_device time device host metric_type sensor value ---- ------ ---- ----------- ------ ----- 1535575550000000000 123456 foo.com counter efg 1 1535575550000000000 123456 foo.com counter efg 1 1535575550000000000 234567 foo.com counter efg 1 1535575550000000000 234567 foo.com counter hij 2 1535575550000000000 234567 foo.com counter efg 1 1535575550000000000 345678 foo.com counter nice 1 1535575550000000000 358168 foo.com counter nice 1 1535575550000000000 345678 foo.com counter nice 1 1535575550000000000 345678 foo.com counter nice 4 1535575550000000000 345678 foo.com counter efg 1 1535575550000000000 345678 foo.com counter efg 12
我尝试过使用这样的子查询,但没有得到预期的结果。它显示空响应。
SELECT top(incoming_devices_count,5) FROM (SELECT sum(device) as incoming_devices_count FROM incoming_events_by_device WHERE sensor='nice' AND time > now() - 30m group by device)
最佳答案
找到查询。
select top(total, 3), device from (select sum(value) as total from incoming_events_by_device where sensor='nice' AND time > now() - 30m group by device);
关于influxdb - 在对一段时间内的值进行求和后,如何获得 influxdb 中的前 5 个结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52103298/