Event filter based on previous event

0

I want to trigger a Lambda function in an event driven way.

My final goal is to aggregate a timeseries table that is getting data from a IoT Thing. The IoT data is going directly to a DynamoDB table, and I want to resample this 10 secondly data to a 5 minutes data in another DynamoDB table.

My idea is to somehow compare the latest added item with the previous item, and if it crossed the 00 or 05 minute mark, trigger the lambda function. I want to save lambda executions so is there a way of achieving this in the event filtering?

EDIT: Something that would also help - test if the timestamp value minute is a multiple of 5. I would still have unnecessary activations but way less.

已提問 9 個月前檢視次數 202 次
2 個答案
1

You don't need to use eventFiltering, you can achive that using Lambda BatchWindow. This will invoke your function when the payload size reaches 6MB, the Batch Window reaches its maximum value, or the Batch Size reaches its maximum value. So its important to ensure your BatchSize is large enough to let it wait for the window to trigger.

profile pictureAWS
專家
已回答 9 個月前
  • Thank you for the suggestion. One case that comes to my mind is, if for some connection problem or just cumulative latency, the amount of messages changes to complete that batch. For example, if I had a perfect timeseries that sends data exactly every 10 seconds, I could set a batch size of 30 and calculate on that. But if for some reason we skip one message or delay messages in a cumulative way. Eventually the completion of the batch would be very delayed from the real time stream.

0

Unfortunately, there is no way to do that. You will need to invoke your function for every event and check if you actually need to do something or not, based on some state that you will save somewhere.

profile pictureAWS
專家
Uri
已回答 9 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南