How to search only in selective log streams in AWS?

Viewed 319

If my search pattern is search_pattern and the log group contains many log streams, but I am only interested in the ones with a certain prefix, is there a way to filter to log streams to search from instead of searching the entire log stream using Search Log Stream option? Illustration: Say my log group contains: student-logs-A student-logs-B student-logs-C teacher-logs-A teacher-logs-B teacher-logs-C management-logs-A management-logs-B management-logs-C

I want to search for pattern search_pattern only in log streams starting from 'student-logs'? AWS cli or Console, any solution is okay.

1 Answers

From the AWS Docs, the filter-log-events accepts a list of log streams:

aws logs filter-log-events --log-group-name my-group --log-stream-names LIST_OF_STREAMS_TO_SEARCH --filter-pattern VALID_METRIC_FILTER_PATTERN

If you don't want to provide a list, it also accepts a prefix:

aws logs filter-log-events --log-group-name my-group --log-stream-name-prefix PREFIX --filter-pattern VALID_METRIC_FILTER_PATTERN
Related