Find occurences where signal was 1 for longer than 2 minutes


I have a year worth of data containing some discrete signals (1/0 ie. On/Off) stored in InfluxDB. Someone asked me to find all occurences where the signal was high (1) for longer than 2 minutes. Is it possible to answer this question with an InfluxQL query, or do I need special processing?



I would do this with a Kapacitor job using the StateDuration node. The stateDuration node allows you to track the duration of a field at a specific value and will output a new field called “state_duration”. This can then be utilized in an alert or you could reemit the record into a different InfluxDB table.

|stateDuration(lambda: “signal_state” == 1)

You can also do this as a batch job using a batch node to look at your prior years data. With your new table, you can then report on the number of occurrences of the “high” state value.

1 Like