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?
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
Log groupsFrom 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.