How do I monitor my Lambda function's memory usage?

Last updated: 2021-08-16

I want to monitor my AWS Lambda functions' memory usage. How do I do that?

Resolution

You can use the following AWS services and tools to monitor your Lambda functions' memory usage. For more information on monitoring function metrics, see Monitoring and observability in the Lambda operator guide.

Note: To optimize your Lambda function's memory usage, see Choosing the optimal memory size and Profiling functions with AWS Lambda Power Tuning.

Amazon CloudWatch Logs Insights

CloudWatch Logs Insights allows you to search and analyze log data for memory usage metrics using a specialized query syntax. For more information and example tutorials, see Analyzing log data with CloudWatch Logs Insights.

For an example query that determines the amount of overprovisioned memory, see the Queries for Lambda logs section of Sample queries.

Note: Running CloudWatch Logs Insights queries incurs charges to your AWS account. For more information, see Amazon CloudWatch pricing.

CloudWatch Lambda Insights

CloudWatch Lambda Insights automatically collects memory usage metrics from the Lambda functions where it's installed. For more information and example tutorials, see Using Lambda Insights.

For an example workflow to track and analyze memory usage, see Example workflow to detect function anomalies in the Lambda developer guide.

For an example log event, see the Example telemetry event in the Using Lambda Insights section of the CloudWatch user guide.

Note: Installing the CloudWatch Lambda extension that's required for CloudWatch Lambda Insights incurs charges to your AWS account. For more information, see the Pricing section of Using Lambda Insights.

(For Python functions only) Lambda Powertools

Lambda Powertools allows you to automatically collect memory usage and other metrics from your application. Lambda Powertools currently supports functions written in Python, with support for runtime versions 3.6 and newer.

For more information, see Simplifying serverless best practices with Lambda Powertools.