Skip to content

Exclude some custom filter pattern to give alert.

0

Hey Everyone!!

I have given the metric filter pattern in my Cloudwatch log group for my log groups.

Filter pattern: { $.log_level = "error" || $.log_level = "ERROR" || $.level = "error" || $.level = "ERROR" } So, anytime when we see any Error in logs in such format we got the alert as we have created alarms as well for such pattern, but the thing is, there are few errors which are obvious to get and we don't want to get alert for those cases, I don't see any functionality in AWS to exclude the pattern to ignore such false alerts.

Could somebody help me to suggest any way to handle this? I don't want dev team to make changes as of now.

1 Answer
0

You can modify your CloudWatch Logs filter pattern to exclude specific error patterns while still capturing the ones you want to be alerted on. The CloudWatch agent configuration supports both include and exclude filter types.

For your specific case, you could modify your metric filter pattern to use a combination of filters that include your general error patterns but exclude the specific error patterns you don't want alerts for.

For example, if you want to exclude errors containing a specific message like "ExpectedError", you could use a pattern like:

{ ($.log_level = "error" || $.log_level = "ERROR" || $.level = "error" || $.level = "ERROR") && ($.message != "ExpectedError") }

Alternatively, with CloudWatch Logs subscription filters, you can use selection criteria with the "NOT IN" operator to exclude specific log groups from your filter.

For Lambda functions that process logs from sources like Apache Kafka or Amazon MSK, you can also implement event filtering using the "anything-but" pattern to ignore specific error messages. This approach allows you to filter out known error messages that don't require alerts.

These filtering approaches allow you to reduce false alerts without requiring changes from your development team.
Sources
Account-level subscription filters - Amazon CloudWatch Logs
Manually create or edit the CloudWatch agent configuration file - Amazon CloudWatch
Using event filtering with a self-managed Apache Kafka event source - AWS Lambda
Using event filtering with an Amazon MSK event source - AWS Lambda

answered 10 months ago
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.