Limit in Flux query


I am currently collecting data from a machine via OPC UA, and use Flux for make query.

A “status” variable tells me the state of my machine.

I would like to create a visualization of the time spent in each state (per day and per week). However, when my machine stops, there is no change of status indicating the shutdown of the machine.

For example :


  • 03/03/2022 22:00:00 EXECUTING

(machine shutdown)

  • 04/03/2022 06:00:00 SETUP

So when I try to calculate the time with events.duration(), I get a duration of 8h in EXECUTING mode. Is there a way around this problem?