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

2 minute read
0

I want to monitor the memory usage of my AWS Lambda functions.

Resolution

You can use the following AWS services and tools to monitor your Lambda functions memory usage. For more information, see Monitoring and observability.

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

Amazon CloudWatch Logs Insights

CloudWatch Logs Insights allows you to create a custom query syntax to search and analyze log data for memory usage metrics. For more information, see Analyze log data with CloudWatch Logs Insights.

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

Note: Your AWS account incurs charges when you run CloudWatch Logs Insights queries. 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, see Get started with Lambda Insights.

For an example workflow to track and analyze memory usage, see Example workflow to detect function anomalies.

For an example log event, see Example telemetry event in CloudWatch Lambda Insights.

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

Amazon CodeGuru Profiler (compatible with Python and Java)

The Amazon CodeGuru Profiler integration for Lambda for JVM and Lambda for Python collects performance data on your applications. CodeGuru Profile is compatible with applications written in Java, Python 3.7 through 3.9, and JVM languages such as Scala and other supported runtime environment.

When you profile your applications, you can monitor their metrics and receive recommendations to make them more efficient.

Related information

Operating Lambda: Use CloudWatch Logs Insights

Understanding AWS Lambda behavior using Amazon CloudWatch Logs Insights

AWS OFFICIAL
AWS OFFICIALUpdated 5 months ago