如何使用一个时间范围从Influx获取总和值? [英] How to get the sum value from the Influx using a time range?

查看:68
本文介绍了如何使用一个时间范围从Influx获取总和值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Influx记录了一些串行数据,并显示了这些数据的报告.

I used Influx for recording some serial data, and show the reports of these data.

我有这样的要求:

获取2017年5月11日至2017年5月17日上午07:00至09:00的值的总和.

Get the total sum of the value in the time 07:00 AM to 09:00 AM from 2017-05-11 to 2017-05-17.

在mysql中,这非常简单,因为您可以使用一个查询来获取该值:

In mysql, this is very easy, since you can get this value using one query:

select sum(value) from series where time(time) >= '07:00:00' and time(time) < '09:00:00' and time > '2017-05-11' and time < '2017-05-19'

但是在Influx中(我现在正在使用1.0.2),我看不到任何类似的功能,influx是否支持这样的查询?

But in Influx(I'm using 1.0.2 now), I can't see any functions like this, did influx support the query like this?

推荐答案

您可以使用此-

select sum(value) as summed_value from series where time> '2017-03-10 00:00:00' and time<'2017-05-10 00:00:00';

如果您还想使用小时数获取数据,在这种情况下,您可以使用

Also if you want to get data using hours also ,in such cases you can use

 select sum(value) as summed_value from series where time> now() - 2400h and time<now() - 1200h;

如果这能解决您的问题,请告诉我.

Let me know,if this solves your problem.

这篇关于如何使用一个时间范围从Influx获取总和值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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