InfluxDB连续查询:保留标签

时间:2019-02-01 22:27:59

标签: influxdb

我正在尝试创建CQ并保留标签。

我的数据看起来像这样;值是浮点数,然后有很多标签。

select * from single_measurements order by time desc limit 10
name: single_measurements
time                     clientId machineId sensorGroupId sensorId typeId value
----                     -------- --------- ------------- -------- ------ -----
2019-02-01T22:19:03.155Z 8219     31        31            1003     1      -5728.96875
2019-02-01T22:19:03.155Z 8219     31        31            1002     1      5435.63525390625
2019-02-01T22:19:03.155Z 8219     31        31            1001     1      1859.4556884765625
2019-02-01T22:19:03.155Z 8219     31        31            1000     1      13231.85546875
2019-02-01T22:19:02.155Z 8219     31        31            1003     1      -5728.91943359375
2019-02-01T22:19:02.155Z 8219     31        31            1002     1      5435.68115234375
2019-02-01T22:19:02.155Z 8219     31        31            1001     1      1859.562744140625
2019-02-01T22:19:02.155Z 8219     31        31            1000     1      13232.0205078125
2019-02-01T22:19:01.155Z 8219     31        31            1003     1      -5728.92138671875
2019-02-01T22:19:01.155Z 8219     31        31            1002     1      5435.7177734375

1)我正在创建政策:

create retention policy "a_year" on "mydb" duration 52w replication 1

2)创建CQ

create continuous query "cq_15s" on "mydb" 
BEGIN SELECT mean(*) into "a_year"."downsampled_value" from "single_measurements" GROUP BY time(15s),* 
end

3)等待15秒并运行此查询

select * from "a_year"."downsampled_value" limit 10

结果为空。我还意识到我可以写错测量名称,也不会出错。

顺便说一句...。这给了我一个非空的结果:

SELECT mean(*) FROM single_measurements GROUP BY time(15s),*

环境:

Connected to http://localhost:8086 version 1.6.4
InfluxDB shell version: 1.6.4

显示连续查询:

name: _internal
name query
---- -----

name: ketag
name    query
----    -----
cq_15s  CREATE CONTINUOUS QUERY cq_15s ON ketag BEGIN SELECT mean(*) INTO ketag.a_year.downsampled_value FROM ketag.autogen.single_measurements GROUP BY time(15s), * END
cq_15s2 CREATE CONTINUOUS QUERY cq_15s2 ON ketag BEGIN SELECT mean(*) INTO ketag.a_year.downsampled_value2 FROM ketag.autogen.single_measurements GROUP BY time(15s) END

0 个答案:

没有答案