influxdb 1.X按时间分组查询不起作用



我正在使用influxdb 1.7

我有一个名为";测试";像低于

> SELECT * FROM test
name: test
time                code    host        f_range         value
----                ---     ----        -------         -----
1610532240000000000 a       localhost   0.101~0.200     7
1610532240000000000 a       localhost   0.401~0.500     1
1610532240000000000 b       localhost   0.101~0.200     3
1610532300000000000 b       localhost   0.101~0.200     3
1610532300000000000 b       localhost   0.201~0.300     1
1610533020000000000 a       localhost   0.101~0.200     4
1610533020000000000 a       localhost   0.201~0.300     1
1610533020000000000 a       localhost   0.401~0.500     1
1610533020000000000 b       localhost   0.101~0.200     6
1610533620000000000 a       localhost   0.101~0.200     11
1610533620000000000 b       localhost   0.101~0.200     8

我还可以让它按标签值分组,比如。。。

> SELECT sum("value") FROM "test" WHERE ("code" =~ /^a$/ AND "host" =~ /^localhost$/) AND time >= now() - 30m GROUP BY "f_range" fill(0)
name: test(0)
tags: f_range=0.101~0.200
time                sum
----                ---
1610500909884441460 22
name: test
tags: f_range=0.201~0.300
time                sum
----                ---
1610500909884441460 1
name: test
tags: f_range=0.401~0.500
time                sum
----                ---
1610500909884441460 2

但是,当我向查询添加time(1m)条件时,它什么也不返回。我想知道在这种情况下我应该检查什么。

> SELECT sum("value") FROM "test" WHERE ("code" =~ /^a$/ AND "host" =~ /^localhost$/) AND time >= now() - 30m GROUP BY time(1m), "f_range" fill(0)
>

感谢

我发现了问题所在。事实上,时间戳是错误的。现在是UTC时间。我已经把这些数据从python客户端放了出来,它需要额外的转换。

我在+09区。所以…时间戳表示从现在起9小时后。

我更改了我的蟒蛇3代码

single = {'measurement':'test', 'tags': tags, 'time': date_timestamp.strftime('%Y-%m-%dT%H:%M:%S+09'), 'fields': {'value': value}} 

datetime_stamp变量是python 中的datetime类型

最新更新