Using customized JSON event patterns - Common use cases - AWS User Notifications

Using customized JSON event patterns - Common use cases

Event rules are used to receive notifications about specific events. To apply additional filters to your event rules, you can customize your event patterns for those rules. Advanced filtering options include:

  • Suffix filtering - match against characters at the end of a value

  • $or matching - use a single rule to check if conditions across several different fields are true

  • Equals-ignore-case - ignore case sensitivity

This topic includes JSON samples for commonly used event patterns and additional information on the EventBridge console's rule builder. For more event pattern examples, see Content filtering in Amazon EventBridge event patterns in the Amazon EventBridge User Guide.

JSON samples for common use cases

CloudWatch alarm that specifies that alarmName must exist

{ "detail": { "alarmName": [ { "exists": true } ] } }

Amazon EC2 instance state changed to "terminated", "stopping", "stopped", or "shutting-down"

{ "detail": { "state": ["terminated", "stopping", "stopped", "shutting-down"] } }

Amazon EC2 instance state change notification using $or matching

{ "detail": { "$or": [ { "state": [ "running" ] }, { "state": [ "terminated" ] } ] } }

Using the EventBridge console's rule builder

For more help building rules, you can use the EventBridge console's rule builder when creating Event Patterns. Use the Event Pattern Builder and the in-place tester to try out your patterns.

Note

You can test rules in the Pattern Builder without creating them.

While testing, remove the source and detail type fields from the event pattern you create.