Status monitoring of sensor

Hi All,

We are getting ON|OFF data from a sensor. The ON is indicated by 1 and OFF as ‘0’. The data sample is:
2018-01-12T04:37:52.709Z 1
2018-01-12T04:39:18.733Z 0
2018-01-12T04:39:56.01Z 1
2018-01-12T04:41:31.119Z 1
2018-01-12T04:43:01.559Z 1
2018-01-12T04:44:33.671Z 1
2018-01-12T04:44:51.847Z 0
2018-01-12T04:44:56.256Z 1
2018-01-12T04:46:30.759Z 1
We need to summarize these data for monitoring OFF duration.
For example : Start_time, End_Time. I was exploring ways using CQs and Kapacitor script, but there are two problems:

  1. We need to have informantion about the previous state of sensor(ON | OFF)
  2. How can we get the time stamp.
    Third option we have is to write our own service, that will be fetching data from DB at every 10 seconds, but I am more worried that it may not have any impact on the server.

We are looking for some efficient methods.

I’m a newbie, but would the AlertNode’s statechangesonly method play into a solution?