在一段时间内的值总和后,如何在 influxdb 中获得前 5 个结果
How do I get top 5 results in influxdb after sum of values over a period
鉴于 InfluxDB 中的以下测量,我想在 Grafana 中显示一个 table,其中包含给定传感器最常出现的设备的前 2 个结果。
因此,以下数据的预期结果将是 table 和 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 中的以下测量,我想在 Grafana 中显示一个 table,其中包含给定传感器最常出现的设备的前 2 个结果。 因此,以下数据的预期结果将是 table 和 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);