I am trying to get the status of lambda function as failed or successful based on the presence of error/exceptions along with the timestamp of lambda start and end time to be shown in cloudwatch dashboard. I am succesfull in getting the timestamps but not sure how to get the status. here is what i have tried:
fields @timestamp, @message, @type
| filter @type in ["START", "END", "REPORT"] or @message like /(?i)(error|exception)/
| parse @message /(?[0-9a-f-]{36})/
| parse @log //aws/lambda/(?[^/]+)/
| stats
earliest(@timestamp) as start_time,
latest(@timestamp) as end_time,
count(*) as total_count,
count(@message like /(?i)(error|exception)/ or @message like /Task timed out/ or @message like /Function Error/) as error_count
by functionName, requestId
| sort by start_time desc
| fields
functionName,
requestId,
start_time,
end_time,
(error_count > 0) as failed,
(error_count = 0) as successful
| limit 100