How to filter CloudWatch Logs Insights by a given string
- Tomasz Łakomy
The best way to filter CloudWatch Logs Insights by a given string is to use the
filter command combined with a regular expression, like this:
fields @timestamp, @message | filter @message like /your filter goes here/ | sort @timestamp desc | limit 20
Make sure to always add a
limit clause to your query, otherwise you might end up with a huge amount of data. Not only you most likely don't need to see 100k entries, you may also incur additional costs - consult the Amazon CloudWatch pricing page for more details.