Hi, I store on Influx the changes of a signal so in my data I can find something like this:
_time, -value, signal
2023-08-09T10:47:51.953Z, true, status
2023-08-11T10:47:51.953Z, false, status
2023-08-12T10:47:51.953Z, true, status
Of those signals, I would like to calculate the amount of time that they have been up.
The problem comes when the first value in the range is false because I don’t know when it became true. So to solve this problem I make a range to look back in the past (start: realStart - 1mo, stop: realtStart), sort desc the results by _time, pick the first element, and union the results with the right range.
This solution has worked for a while but now a signal that has been up for more than a month went down so when I look back in time using the previous logic I cannot find it anymore.
I thought that increasing the look-back time from 1mo to 1y would bring again the value to the results but the query takes really a lot of time to execute and the problem is still there because if a signal stays up for more than a year I will not find anymore.
Has anyone encountered a similar problem? How did you solve it?