InfluxQL的InfluxDB查询结果与类似SQL的查询不同

时间:2020-09-08 05:01:37

标签: go influxdb

我是InfluxDB的新手,在窗口数据处理方面遇到问题。

在我的InfluxDB中提供以下原始数据:

master^2

然后我想通过以下命令每1小时对数据进行一次窗口处理,它可以达到我期望的效果。

D

但是,我将Go与仅支持InfluxQL的InfluxDB客户端一起使用,首先我的查询转到此以确保一切正确,并且看起来正确。

> select time,count from "myMeasurement" where time >= '2020-01-10T00:00:00Z' and time <= '2020-01-10T10:00:00Z'
name: myMeasurement
time                 count
----                 -----
2020-01-10T00:00:00Z 6
2020-01-10T01:00:00Z 17
2020-01-10T02:00:00Z 51
2020-01-10T03:00:00Z 37
2020-01-10T04:00:00Z 46
2020-01-10T05:00:00Z 22
2020-01-10T06:00:00Z 31
2020-01-10T07:00:00Z 58
2020-01-10T08:00:00Z 39
2020-01-10T09:00:00Z 53
2020-01-10T10:00:00Z 87

但是当我使用> select sum(count) from "myMeasurement" where time >= '2020-01-10T00:00:00Z' and time <= '2020-01-10T10:00:00Z' group by time(1h) name: myMeasurement time sum ---- --- 2020-01-10T00:00:00Z 6 2020-01-10T01:00:00Z 17 2020-01-10T02:00:00Z 51 2020-01-10T03:00:00Z 37 2020-01-10T04:00:00Z 46 2020-01-10T05:00:00Z 22 2020-01-10T06:00:00Z 31 2020-01-10T07:00:00Z 58 2020-01-10T08:00:00Z 39 2020-01-10T09:00:00Z 53 2020-01-10T10:00:00Z 87 函数时,输出非常奇怪,最后一行似乎移到了第一行,您可以看到计数为result, err := queryAPI.Query(context.Background(), ` from(bucket:"metrics") |> range(start: 2020-01-10T00:00:00Z, stop: 2020-01-10T10:00:00Z) |> filter(fn: (r) => r._measurement == "myMeasurement" ) `) time=2020-01-10 00:00:00 +0000 UTC, count = 6 time=2020-01-10 01:00:00 +0000 UTC, count = 17 time=2020-01-10 02:00:00 +0000 UTC, count = 51 time=2020-01-10 03:00:00 +0000 UTC, count = 37 time=2020-01-10 04:00:00 +0000 UTC, count = 46 time=2020-01-10 05:00:00 +0000 UTC, count = 22 time=2020-01-10 06:00:00 +0000 UTC, count = 31 time=2020-01-10 07:00:00 +0000 UTC, count = 58 time=2020-01-10 08:00:00 +0000 UTC, count = 39 time=2020-01-10 09:00:00 +0000 UTC, count = 53 time=2020-01-10 10:00:00 +0000 UTC, count = 87 的行应该是最后一行但是没有,有人可以帮我吗?

aggregateWindow

0 个答案:

没有答案
相关问题