Accessing Amazon CloudWatch logs for AWS Lambda - AWS Lambda

Accessing Amazon CloudWatch logs for AWS Lambda

AWS Lambda automatically monitors Lambda functions on your behalf, reporting metrics through Amazon CloudWatch. To help you troubleshoot failures in a function, Lambda logs all requests handled by your function and also automatically stores logs generated by your code through Amazon CloudWatch Logs.

You can insert logging statements into your code to help you validate that your code is working as expected. Lambda automatically integrates with CloudWatch Logs and pushes all logs from your code to a CloudWatch Logs group associated with a Lambda function, which is named /aws/lambda/<function name>.

You can view logs for Lambda functions using the Lambda console, the CloudWatch console, the AWS Command Line Interface (AWS CLI), or the CloudWatch API. This page describes how to view logs using the Lambda console.

Prerequisites

Your execution role needs permission to upload logs to CloudWatch Logs. You can add CloudWatch Logs permissions using an AWS managed policy provided by Lambda. For more information, see AWS managed policies for Lambda features.

Pricing

There is no additional charge for using Lambda logs; however, standard CloudWatch Logs charges apply. For more information, see CloudWatch pricing.

Using the Lambda console

The following section describes how to view logs for your function on the Lambda console.

To view logs using the Lambda console

  1. Open the Functions page on the Lambda console.

  2. Choose a function.

  3. Choose Monitoring.

    
            Events

    A graphical representation of the metrics for the Lambda function are shown.

  4. Choose View logs in CloudWatch.

Note

Logs may not be immediately available after invocation. We recommend waiting 5 to 10 minutes before checking your execution role.

Using the AWS CLI

To debug and validate that your code is working as expected, you can output logs with the standard logging functionality for your programming language. The Lambda runtime uploads your function's log output to CloudWatch Logs. For language-specific instructions, see the following topics:

What's next?