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.

asked 8 months ago196 views
2 Answers
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
EXPERT
answered 8 months ago
  • 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
EXPERT
Uri
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions