We are working with Azure IoT Hub which sends the data to Azure TSI, and we're utilizing the TSI Rest APIs to get the data from it.
Format of data-
Raw telemetry looks like -
{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":1, "timestamp":123456, plc_id:1}
{"status":0, "timestamp":123456, plc_id:1}
I used 123456 just for example in timestamp.
I need to calculate the downtime ( last occurrence of 0 - first occurrence of 0 ), and then ignore status 1, again calculate the downtime for next 0s after 1.
And we need to do it using TSI Rest APIs only. Any idea?
TSI Query engine does not provide windowed calculation between events. Calculating down time by comparing two timestamps is not possible.
TSI only supports windowing based on time interval using aggregate series API. You will need to retrieve the raw events using GetEvents API and perform/apply your custom windowing calculation on the client side.