I have few lambda cron jobs functions. I would like to run another lambda function once a day and grab the latest log for each lambda. Based on this log I would generate a simple report and notify slack.
The lambda function wrote in python using boto3.
The report should look something like this:
Lambda-1 - ERROR - LOG
Lambda-2 - Succeeded
Lambda-3 - Succeeded (warn) - warn_message
Currently, I face an issue with grabbing the latest lambda log and status from cloudwatch insights.
I have played a bit with this query :
fields @timestamp, @message
| sort @timestamp desc
| filter level IN ["warn","info","error"] |
limit 1
This query returns the latest log with this log level. But, this is not the latest lambda invocation. Therefore, there might be some false logs generated.
My question is:
- Is there any cloudwatch insight query to grab the latest lambda invocation status and log?
- Is there any simpler way to generate the desired report?
Thanks in advance.