Latest values in timestream for specific device

65 Views Asked by At

I am using Timestream to keep the MQTT messages coming to my AWS IoT broker. Messages are in UDMI format. Mostly I am keeping pointset messages, which are messages with current state of the device. Device can have multiple datapoints, and every datapoint is kept as separate row in the Timestream DB.

Most of devices are sending messages in time interval of 60 seconds, so if i want to get the latest state of some device i just query for that specific device for the last 1.5 minutes. I added .5 minutes just as a delta, so i can be sure that i would actually have all the latest datapoints from pointset message.

The issue is, that a few device types are sending new pointset message only when there is a change in the device state. So if there was no change on some device for 3 days, i would not get any message for that specific device in that period.

My questions is, how can i fetch the latest state of specific device, considering i have arbitrary number of datapoints for those devices?

For example I have Lighting device of type XYZ, and that device has 5 data points, I also have Lighting device of type ABC which has 2 datapoints. So for one device i would need to fetch 5 latest inserts in timestream and for other 2. (There is a lot of device types, so specifying the number of last rows for specific device is not really option i would like to go)

Kind regards

0

There are 0 best solutions below