oblio
oblio

Reputation: 1623

Is there a way to easily get only the log entries for a specific AWS Lambda execution?

Lambda obviously tracks executions, since you can see data points in the Lambda Monitoring tab.

Lambda also saves the logs in log groups, however I get the impression that Lambda launches are reused if happening in a shorter interval (say 5 minutes between launches), so the output from multiple executions gets written to the same log stream.

This makes logs a lot harder to follow, especially due to other limitations (the CloudWatch web console is super slow and cumbersome to navigate, aws log get-log-events has a 1MB/10k message limitation which makes it cumbersome to use).

Is there some way to only get Lambda log entries for a specific Lambda execution?

Upvotes: 0

Views: 1265

Answers (2)

jellycsc
jellycsc

Reputation: 12259

My current approach is to use CloudWatch Logs Insights to query for the specific logs that I'm looking for. Here is the sample query:

fields @timestamp, @message
| filter @requestId = '5a89df1a-bd71-43dd-b8dd-a2989ab615b1'
| sort @timestamp
| limit 10000

Upvotes: 2

Jason Wadsworth
Jason Wadsworth

Reputation: 8887

You can filter by the RequestId. Most loggers will include this in the log, and it is automatically included in the START, END, and REPORT entries.

Upvotes: 3

Related Questions