How can I filter CloudWatch logstreams to the logstreams of failed invocations?

Viewed 625

I have a Lambda function that has a success rate of over 99% (which is nice).

Occasionally there is an invocation which results in an error. I would like to view the log of that one invocation.

How can I find the cloudwatch logstream which contains the error invoke?

1 Answers

To do this you need to apply filter patterns across the entire log group, which will query all logstreams.

If you're looking for a specific error phrase you can wrap it in double quotes such as "ERROR".

From the console

  • Go to the CloudWatch service screen
  • Click Log groups
  • Click on your log group
  • Click "Search All"
  • Enter your pattern in the "Filter events" text box

From the CLI

Use the filter-log-events function. An example is below

aws logs filter-log-events --start-time 1593967410000 --end-time 15945722100000 --log-group-name /aws/lambda/function-name --filter-pattern ERROR --output text

For examples of how to use more complex filter patterns take a look at the Filter and Pattern Syntax page.

Related