使用InfluxDB差异功能 [英] Using InfluxDB difference function

查看:853
本文介绍了使用InfluxDB差异功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的influxdb数据库中有一些测量数据,可以使用以下数据进行查询:

I have some measurement data in my influxdb database which I can query with:

select * from E_real_con
名称:E_real_con
时间值
---- -----
1537920001044785525 | 57160036.00
1538006401069651036 | 57227208.00
1538092800108297103 | 57294112.00
1538179200697333731 | 57366108.00

select * from E_real_con
name: E_real_con
time value
---- -----
1537920001044785525 | 57160036.00
1538006401069651036 | 57227208.00
1538092800108297103 | 57294112.00
1538179200697333731 | 57366108.00

但是,值"是一个累积值,我想获得两个连续值之间的差值/差异.

However, "value" is a cumulative value and I would like to get the delta/difference between two consecutive values.

我尝试了以下操作:

SELECT difference(last(value)) FROM E_real_con WHERE time >= now() - 7d GROUP BY time(1d) fill(null)

但是,我收到以下错误消息:

However, I get the following error message:

ERR: unsupported difference iterator type: *query.stringInterruptIterator

我很高兴获得一些提示和反馈,以解决我的问题.

I would be happy to get some hints and feedback how to solve my issue.

我正在使用influxdb 1.6.1

I am using influxdb 1.6.1

非常感谢! 克里斯多夫(Christoph)

Thanks a lot! Christoph

推荐答案

我找到了解决方案.以下两个错误必须纠正:

I found the solution. The following two mistakes had to be corrected:

1)测量中的值是字符串"类型,而不是浮点"类型.由于数据来自nodered,因此在将数据写入influxdb之前,我清除了数据库并在nodered中使用parseFloat(). 顺便说一句:您可以通过以下方式检查测量字段的数据类型:

1) The values in the measurement were of type "string" and not "float". As the data was coming from nodered, I cleared the database and used parseFloat() in nodered before writing the data to influxdb. BTW: you can check the datatype of your measurement field by:

SHOW FIELD KEYS FROM E_real_con

2)看来查询命令需要一个"where"

2) It seems that the query command requires a "where"

这有效:

SELECT difference(last(value)) FROM E_real_del WHERE time >= now() - 7d GROUP BY time(1d)

而:

SELECT difference(last(value)) FROM E_real_del GROUP BY time(1d)

不起作用.

我希望这可以对其他人有所帮助.

I hope this might help someone else.

这篇关于使用InfluxDB差异功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆