Skip to content

What is the easiest way to view logs for a Lambda function in AWS CloudWatch?

0

What is the easiest way to view logs for a Lambda function in AWS CloudWatch? I'm using Lambda and want to see my function's logs after it runs. Where exactly in CloudWatch do I find them, and how can I filter the logs by a specific invocation?

1 Answer
1
Accepted Answer

There are three main ways to view your Lambda function logs in CloudWatch:

  1. Using the Lambda console:
  • Go to the Lambda console
  • Select your function
  • Choose the "Monitor" tab
  • View the execution results in the "Logs" section
  • You can also check the "Details" section when using the console test feature
  1. Using the CloudWatch console:
  • Open the CloudWatch console
  • Navigate to the "Log groups" page
  • Find and select the log group for your Lambda function (it will be named "/aws/lambda/your-function-name")
  • Click on a log stream to see the detailed logs
  1. Using the AWS Command Line Interface (CLI):
  • You can retrieve logs using the AWS CLI with the --log-type command option
  • The logs can be decoded using base64

Each log stream corresponds to an instance of your function. To filter logs for a specific invocation, you can use AWS X-Ray to record details about the request and the log stream in the trace. The Lambda runtime automatically logs the start and end of each function invocation, including details like request ID, duration, memory usage, and more. Any console.log statements (or equivalent in your programming language) will appear in these logs.
Sources
CloudWatch for Newbies | AWS re:Post
Log and monitor Node.js Lambda functions - AWS Lambda
Viewing CloudWatch logs for Lambda functions - AWS Lambda
Log and monitor TypeScript Lambda functions - AWS Lambda

answered a year ago
AWS
SUPPORT ENGINEER
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.