Find the most expensive Lambda function invocations with CloudWatch Logs Insights
AWS Lambda pricing is based on the number of requests and the duration of the function execution. As such - the shorter the execution, the cheaper it is.
In this post, we will show you how to use CloudWatch Logs Insights to find the most expensive Lambda function invocations.
filter @type = "REPORT"
| fields @requestId, @billedDuration
| sort by @billedDuration desc
@billedDuration is the key param here - it is the duration of the function execution in milliseconds. The
@requestId is the unique identifier of the function invocation which you can use to find the corresponding log entry.