I have a piece of machinery with PLC tags that record either 1 if it is running or 0 if it is down. I am trying to use this to calculate runtime, not just cumulatively but also as a series of up and downtimes such as 3.4 hrs running, 2.4 down, 2.2 running, etc.
I have tried using the transaction command but it does not seem to be grouping things properly. I would like to have transactions where the measurement value is all 1 and then once the first 0 appears a new transaction is formed and goes on until the next 1 appears and so on and so forth so I can get the duration for each transaction.
The posted code is very basic but has the basis for my search. I have tried using startswith, endswith, and maxpause, etc. and they don't seem to be grouping properly.
index="index" AppName="Appname" ItemName="Machine1"
| transaction Measurement
| stats sum(duration) as duration by Measurement
... View more