Skip to content
Software capabilities
Amazon CloudWatch

Find matching events in a CloudWatch log group

Use FilterLogEvents for a bounded, paginated log search. Use aws logs tail for a quick look at recent events or to follow a running stream.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. API: CloudWatch Logs FilterLogEvents
  2. CLI: aws logs tail
API

CloudWatch Logs FilterLogEvents

Filter a log group by time range, filter pattern, or a stream name or prefix.

Read source: AWS FilterLogEvents API reference
Requirements
AWS credentials with logs:FilterLogEvents for the log group. Provide either logGroupName or logGroupIdentifier.
Limitations
Each response can hold up to 1 MB or 10,000 events. Even an empty page can have a nextToken. Keep paging until the token is absent.
CLI

aws logs tail

Print recent matching events. Add --follow to keep polling, or use --filter-pattern to narrow the output.

Read source: AWS CLI logs tail command
Requirements
An AWS CLI profile in the log group’s Region with logs:FilterLogEvents and the log group name.
Limitations
The CLI defaults to the last 10 minutes and does not guarantee exact timestamp order across streams.

Example shell

aws logs tail /aws/lambda/example --since 30m --filter-pattern 'ERROR'