I have the same exact need in my company's IoT project.
Sensors send values at irregular times, only when their reading change.
The last stored value is to be considered "the" value until the next one.
For simplicity, let's say the value is a boolean status ("presence"/"absence" 
in our case) encoded as "1" or "0".
I need to count the number of devices that are in state "1" for fixed time 
intervals. Using 

SELECT COUNT(value) ... GROUP BY TIME (1h) FILL(previous)

the filling is done _after_ the GROUPing, so the count doesn't reflect the 
number of devices that are _simultaneously_ in state "1". Using SUM() instead 
of COUNT() makes no difference.
The fact that Influx doesn't accept arithmetic expression as arguments of 
aggregate functions makes it difficult to work around this limitation.

Another thing that would help immensely would be a working INTEGRAL function: 
if it were possible to do something like:

SELECT INTEGRAL("value" != 0 ? 1 : 0) ... GROUP BY TIME (1h) FILL(previous)

one could easily extract the fraction of time inside every fixed interval when 
the value satisfied a given condition (value<>0 in my example, but could be 
anything).

At the moment I am querying all the raw data in the time interval and sending 
it to AWS Lambda for processing, but it would be much better if this kind of 
time-based manipulations were possible directly inside InfluxDB.

Thank you for any suggestion.

-- 
Remember to include the version number!
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to influxdb+unsubscr...@googlegroups.com.
To post to this group, send email to influxdb@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/b1a8808d-f620-46b9-996a-e8efc6ecc732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to