내용으로 건너뛰기

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개 답변
1
수락된 답변

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

답변함 일 년 전

AWS
지원 엔지니어

검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠