Influx聚合查询return错误时间
Influx aggregation query return wrong time
我是一个新的 influxdb 用户,我的 influxDB 版本是 1.7.1。我在涌入时遇到问题。
我有一个名为 lv_table 的测量,Listing_id 和 event_type 是标签,event_id 是字段
select * from "lv_table" limit 10
name: lv_table
time Listing_id event_id event_type
---- ---------- -------- ----------
1542711774019000 105202696 4 "leads"
1542711774020000 105497566 66 "view"
1542711774021000 95532296 66 "view"
1542711774021000 98830991 1 "leads"
1542711774022000 105456186 66 "view"
1542711774023000 94326731 66 "view"
1542711774025000 104584666 66 "view"
1542711774028000 105603346 66 "view"
1542711774035000 99913981 66 "view"
1542711774037000 105430516 3 "leads"
但是当我在 cli 中使用 "precision RFC3339" 时,该查询 return 1970 年的日期如 '1970-01-18T20:31:51.774019Z' 但正确的时间是 '2018-11- 20T20:31:51.774019Z'
> precision RFC3339
> select * from "lv_table" limit 10
name: lv_table
time Listing_id event_id event_type
---- ---------- -------- ----------
1970-01-18T20:31:51.774019Z 105202696 4 "leads"
1970-01-18T20:31:51.77402Z 105497566 66 "view"
1970-01-18T20:31:51.774021Z 95532296 66 "view"
1970-01-18T20:31:51.774021Z 98830991 1 "leads"
1970-01-18T20:31:51.774022Z 105456186 66 "view"
1970-01-18T20:31:51.774023Z 94326731 66 "view"
1970-01-18T20:31:51.774025Z 104584666 66 "view"
1970-01-18T20:31:51.774028Z 105603346 66 "view"
1970-01-18T20:31:51.774035Z 99913981 66 "view"
1970-01-18T20:31:51.774037Z 105430516 1 "leads"
>
有什么问题,我该如何解决?
在聚合查询中,它变得值得...并在 2016 年显示时间,但它应该在 2018-11-20 日期
1468800000000000 = 2016 年 7 月 18 日,星期一 12:00:00 上午
select count(*) as count_leads from "lv_table" where "event_type" = '"leads"' and time < 1542745800000000 group by Listing_id,time(1d)
>...
name: lv_table
tags: Listing_id=99965506
time count_leads_event_id
---- --------------------
1468800000000000 1
name: lv_table
tags: Listing_id=99965771
time count_leads_event_id
---- --------------------
1468800000000000 2
name: lv_table
tags: Listing_id=99966146
time count_leads_event_id
---- --------------------
1468800000000000 1
name: lv_table
tags: Listing_id=99966736
time count_leads_event_id
---- --------------------
1468800000000000 3
...
如果我不按时间分组,时间将等于0
自 1970 年 1 月 1 日以来,Influxdb 在内部将时间戳存储为纳秒,因此您的第一个数据点实际上被解释为:
1542711774019000 ns -> 1542711 s -> Sun Jan 18 20:31:51 UTC 1970
这就是您在 cli.
中使用 "precision RFC3339" 时看到的内容
不确定你是怎么得到的
1468800000000000 = Monday, July 18, 2016 12:00:00 AM
1468800000000000 ns -> 1468800 s -> Sun Jan 18 00:00:00 UTC 1970
这是您的第一个数据点时间戳四舍五入为 1 天。
您没有描述如何将数据放入 table。在 Influx HTTP API 中,您可以使用可选查询参数指定输入时间戳数据的精度(参见 InfluxDB HTTP API reference)。
influx 中的 Precision
设置说明了如何处理输入时间戳数据。输入的时间戳值始终是整数(不是 rfc3339 字符串)。并且这个整数是根据精度设置来解释的。
precision=[ns,u,ms,s,m,h] Optional Sets the precision for the supplied Unix time values. InfluxDB assumes that timestamps are in nanoseconds if you do not specify precision
(see Influx docs here)
它也影响查询结果的输出格式。请参阅以下示例:
```
> precision ns
> insert demo value="precisionNS TS treated as nanoseconds" 1543220939000000000
> precision s
> insert demo value="precisionS TS treated as seconds" 1543220940
> precision ms
> insert demo value="precisionMS TS treated as ms" 1543220940123
> precision rfc3339
> select * from demo
name: demo
time value
---- -----
2018-11-26T08:28:59Z precisionNS TS treated as nanoseconds
2018-11-26T08:28:59.123456789Z precisionNS TS treated as nanoseconds
2018-11-26T08:29:00Z precisionS TS treated as seconds
2018-11-26T08:29:00.123Z precisionMS TS treated as ms
>
> precision s
> select * from demo
name: demo
time value
---- -----
1543220939 precisionNS TS treated as nanoseconds
1543220939 precisionNS TS treated as nanoseconds
1543220940 precisionS TS treated as seconds
1543220940 precisionMS TS treated as ms
>
> precision ns
> select * from demo
name: demo
time value
---- -----
1543220939000000000 precisionNS TS treated as nanoseconds
1543220939123456789 precisionNS TS treated as nanoseconds
1543220940000000000 precisionS TS treated as seconds
1543220940123000000 precisionMS TS treated as ms
```
我是一个新的 influxdb 用户,我的 influxDB 版本是 1.7.1。我在涌入时遇到问题。
我有一个名为 lv_table 的测量,Listing_id 和 event_type 是标签,event_id 是字段
select * from "lv_table" limit 10
name: lv_table
time Listing_id event_id event_type
---- ---------- -------- ----------
1542711774019000 105202696 4 "leads"
1542711774020000 105497566 66 "view"
1542711774021000 95532296 66 "view"
1542711774021000 98830991 1 "leads"
1542711774022000 105456186 66 "view"
1542711774023000 94326731 66 "view"
1542711774025000 104584666 66 "view"
1542711774028000 105603346 66 "view"
1542711774035000 99913981 66 "view"
1542711774037000 105430516 3 "leads"
但是当我在 cli 中使用 "precision RFC3339" 时,该查询 return 1970 年的日期如 '1970-01-18T20:31:51.774019Z' 但正确的时间是 '2018-11- 20T20:31:51.774019Z'
> precision RFC3339
> select * from "lv_table" limit 10
name: lv_table
time Listing_id event_id event_type
---- ---------- -------- ----------
1970-01-18T20:31:51.774019Z 105202696 4 "leads"
1970-01-18T20:31:51.77402Z 105497566 66 "view"
1970-01-18T20:31:51.774021Z 95532296 66 "view"
1970-01-18T20:31:51.774021Z 98830991 1 "leads"
1970-01-18T20:31:51.774022Z 105456186 66 "view"
1970-01-18T20:31:51.774023Z 94326731 66 "view"
1970-01-18T20:31:51.774025Z 104584666 66 "view"
1970-01-18T20:31:51.774028Z 105603346 66 "view"
1970-01-18T20:31:51.774035Z 99913981 66 "view"
1970-01-18T20:31:51.774037Z 105430516 1 "leads"
>
有什么问题,我该如何解决?
在聚合查询中,它变得值得...并在 2016 年显示时间,但它应该在 2018-11-20 日期
1468800000000000 = 2016 年 7 月 18 日,星期一 12:00:00 上午
select count(*) as count_leads from "lv_table" where "event_type" = '"leads"' and time < 1542745800000000 group by Listing_id,time(1d)
>...
name: lv_table
tags: Listing_id=99965506
time count_leads_event_id
---- --------------------
1468800000000000 1
name: lv_table
tags: Listing_id=99965771
time count_leads_event_id
---- --------------------
1468800000000000 2
name: lv_table
tags: Listing_id=99966146
time count_leads_event_id
---- --------------------
1468800000000000 1
name: lv_table
tags: Listing_id=99966736
time count_leads_event_id
---- --------------------
1468800000000000 3
...
如果我不按时间分组,时间将等于0
自 1970 年 1 月 1 日以来,Influxdb 在内部将时间戳存储为纳秒,因此您的第一个数据点实际上被解释为:
1542711774019000 ns -> 1542711 s -> Sun Jan 18 20:31:51 UTC 1970
这就是您在 cli.
不确定你是怎么得到的
1468800000000000 = Monday, July 18, 2016 12:00:00 AM
1468800000000000 ns -> 1468800 s -> Sun Jan 18 00:00:00 UTC 1970
这是您的第一个数据点时间戳四舍五入为 1 天。
您没有描述如何将数据放入 table。在 Influx HTTP API 中,您可以使用可选查询参数指定输入时间戳数据的精度(参见 InfluxDB HTTP API reference)。
influx 中的Precision
设置说明了如何处理输入时间戳数据。输入的时间戳值始终是整数(不是 rfc3339 字符串)。并且这个整数是根据精度设置来解释的。
precision=[ns,u,ms,s,m,h] Optional Sets the precision for the supplied Unix time values. InfluxDB assumes that timestamps are in nanoseconds if you do not specify precision
(see Influx docs here)
它也影响查询结果的输出格式。请参阅以下示例:
```
> precision ns
> insert demo value="precisionNS TS treated as nanoseconds" 1543220939000000000
> precision s
> insert demo value="precisionS TS treated as seconds" 1543220940
> precision ms
> insert demo value="precisionMS TS treated as ms" 1543220940123
> precision rfc3339
> select * from demo
name: demo
time value
---- -----
2018-11-26T08:28:59Z precisionNS TS treated as nanoseconds
2018-11-26T08:28:59.123456789Z precisionNS TS treated as nanoseconds
2018-11-26T08:29:00Z precisionS TS treated as seconds
2018-11-26T08:29:00.123Z precisionMS TS treated as ms
>
> precision s
> select * from demo
name: demo
time value
---- -----
1543220939 precisionNS TS treated as nanoseconds
1543220939 precisionNS TS treated as nanoseconds
1543220940 precisionS TS treated as seconds
1543220940 precisionMS TS treated as ms
>
> precision ns
> select * from demo
name: demo
time value
---- -----
1543220939000000000 precisionNS TS treated as nanoseconds
1543220939123456789 precisionNS TS treated as nanoseconds
1543220940000000000 precisionS TS treated as seconds
1543220940123000000 precisionMS TS treated as ms
```