将单独的信号流合并到一个表中,并在每个时间间隔为每个信号汇总值

时间:2020-07-06 15:13:18

标签: grafana influxdb

我有一个InfluxDB,每次测量都分别从设备接收数据点,即,对于GPS位置,纬度/经度/海拔高度是三个不同的流,必须分别进行查询。我无法更改应用程序的这一部分。

现在,我想在Grafana中创建一个简单的表格,显示每个时间戳的组合GPS数据集。我已经设法将所有这些信号合并到一个表中,但是现在每个信号都是其自己的行: Screenshot

我的查询如下:

SELECT 
  median(Latitude) as "Lat", 
  median(Longitude) as "Long", 
  median(Altitude) as "Alt", 
  median(TheSpeed) as "Speed" 
FROM
  (SELECT value as "Latitude" FROM "signal-1" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
  (SELECT value as "Longitude" FROM "signal-2" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
  (SELECT value as "Altitude" FROM "signal-5" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
  (SELECT value as "TheSpeed" FROM "signal-4" WHERE $timeFilter  AND deviceId =~/$DeviceID/)
WHERE $timeFilter 
GROUP BY time(1s)

如何将四个单独的信号合并到一个表行中?

谢谢您的帮助,我坚持下去。

1 个答案:

答案 0 :(得分:0)

我找到了解决方法:

这样更改查询:

SELECT 
median(value)
FROM
(SELECT value FROM "signal-1" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
(SELECT value FROM "signal-2" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
(SELECT value FROM "signal-5" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
(SELECT value FROM "signal-4" WHERE $timeFilter  AND deviceId =~/$DeviceID/),
WHERE $timeFilter 
GROUP BY time($timegap), "description" 
FILL(previous)

并将表格格式化为时间序列(而不是“表格”),并使用“描述字段”作为ALIAS BY。

现在看起来就像我需要它的方式: enter image description here

我很惊讶没有人回答这个问题,回想起来这似乎是一个菜鸟问题。 :(