I'm following the instructions here https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html
but it's not working as i'm expecting it to.
I currently have the following cloudwatch log subscription filter pattern: ? "UNKNOWN_TOPIC_OR_PARTITION" ? " SEVERE " ? " severe " ? " FATAL " ? " fatal " - "closing session"
I would like to match any patter with " fatal " whilst excluding "closing session" from the results.
However, the above filter is matching other log output:
To search your logs using the consoleOpen the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ . In the navigation pane, choose Log groups. For Log Groups, choose the name of the log group containing the log stream to search. For Log Streams, choose the name of the log stream to search.
A CloudWatch Alarm is always in one of three states: OK, ALARM, or INSUFFICIENT_DATA.
You can't with event filter in CloudWatch... but you can with Logs Insights
CloudWatch -> CloudWatch Logs -> Logs Insights
Or
CloudWatch -> CloudWatch Logs -> Log groups -> [your service logs] -> [Button Logs Insights]
Logs Insights
So in your case you can with this in the query box
fields @timestamp, @message
| sort @timestamp desc
| filter @message like /SEVERE|severe|FATAL|fatal|closing session/
Now click on run query and you will see only logs that you want with that filters.
Try this Filter pattern:
[(w1="*UNKNOWN_TOPIC_OR_PARTITION*" || w1="*SEVERE*" || w1="*severe*" || w1="*FATAL*" || w1="*fatal*") && w1!="*closing session*"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With