Reporting multiple Lambda failures at different schedules as batch

0

Hi

I'm trying to build a solution using Simple Email Service and a Lambda function that will send an email after some time as a summary, detailing all the lambda failures received in a certain time frame.

The main thing is that I want it to be somehow configurable so I can specify that this lambda function will report at different schedules: you could opt to have X lambda be reported (in batch with other failures) every 5 minutes within an hour, others at 15 minutes every hour, 30, 45, etc.

I was planning to use SQS queues for each possible schedule (one for 5 minutes, for 30 minutes, etc.) or put them in a Dynamo table with an attribute that indicates the schedule. I'm having doubts about if this is the best approach. The reporting function would have a track of each time it reported (and I'd calculate if a failure is within schedule to be reported or not)

Perhaps there is something already in place in AWS that makes it less manual or more efficient?

2 Answers
1

Create a state machine in Step Functions that starts with a lambda function to check for failures and use a combination of wait states and choice states in Step Functions to handle the different reporting intervals.Once the wait period is over, the state machine triggers another lambda function to send the email via SES.

profile picture
answered a year ago
0

Hello.

You can easily configure settings to issue a message the moment a Lambda error occurs.
https://aws.amazon.com/jp/blogs/mt/monitor-your-lambda-function-and-get-notified-with-aws-chatbot/

However, if you are trying to achieve a configuration that sends all errors over a certain period of time as a message, I think you will need to devise a bit.
As you know, I think it is possible to store error messages for a certain period of time in a database (such as DynamoDB) and notify them.
Another method is to run CloudWatch Logs Insights on Lambda for a certain period of time and send the message after querying error messages from Lambda's log group.
This is possible using the "start_query" API and "get_query_results".
However, be aware that this approach can become expensive as the amount of logs increases.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs/client/start_query.html
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs/client/get_query_results.html

profile picture
EXPERT
answered a year 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