I’m having several measurements wich are in a certain range and change only several time a day. I’m trying to construct a query to find the timerange - like start at ‘timestamp xx’ stop at ‘timestamp yy’ - if the value changes.
And I would like to get the starting and stoping timestamp if the value is above or equal to 1000 and also start and stop when it’s below 1000. This state changes several times a day.
I’ve looked through documentation and several tutorials and wasn’t actualy able to find a starting point. Is that even possible or would it be better to do further work the data in something like python. I’m thankfull for any help on this.
it didn’t really help me. I invested a lot of time to get flux running and I did get results like telling me the level change from on to off or from off to on, but as soon as I set the state change from any to any it fails .The expected result would be the start and end timestamp after the state change happens. So I’m looking at a machine that is turnedeither on or off during the day and I need that start and stop timestamp of the “off” durations to use that in another query.
In a seperate query I want to calculate information based on the timerange that I’m trying to get from the above query.
@Sven_Achtelik I think you could accomplish this with the events.duration() function. It’s a little convoluted, but you’d first have to logically assign a _level of either crit, warn, info, or ok, then use the monitor.stateChangesOnly() function (which depends on those four levels). Then ungroup and sort by time again (since monitor.stateChangesOnly() changes the grouping and sorting). Then with the output of events.duration(), you can calculate the stop time by adding the returned duration to the start time of the state: