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.

posta 9 mesi fa202 visualizzazioni
2 Risposte
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
ESPERTO
con risposta 9 mesi fa
  • 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
ESPERTO
Uri
con risposta 9 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande