Event rules control how events flow through your system. Each rule defines a pattern to match incoming events and one or more targets to receive them -- such as Function Compute functions, message queues, or HTTP endpoints. When an event matches a rule's pattern, EventBridge delivers it to all configured targets automatically.
Each rule supports up to five targets, all of which must be in the same region as the rule.
Prerequisites
Before you begin, make sure that you have:
An activated EventBridge service
The required permissions granted to a Resource Access Management (RAM) user
For setup instructions, see Activate EventBridge and grant permissions to a RAM user.
Create an event rule
Creating an event rule involves three steps:
Define basic info -- name and describe the rule.
Set up the event pattern -- specify which events to match.
Configure targets -- choose where to send matched events.
To start, navigate to the Event Rules page:
Log on to the EventBridge console.
In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region.
On the Event Buses page, click the name of the event bus where the rule belongs.
In the left-side navigation pane, click Event Rules.
Step 1: Define basic info
On the Event Rules page, click Create Rule.
In the Configure Basic Info step, enter a rule name in the Name field and a description in the Description field.
Click Next Step.
Step 2: Set up the event pattern
In the Configure Event Pattern step, select an Event Source Type and configure the pattern:
Alibaba Cloud Service Event Sources: Select an Alibaba Cloud service from the Event Source drop-down list and an event type from the Event Type drop-down list.
NoteEvents from Alibaba Cloud services cannot be published to custom event buses. If the current event bus is a custom event bus, this option is unavailable.
Custom Event Source: Select a custom event source from the Event Source drop-down list and specify an event pattern in the Pattern Content code editor. For pattern syntax and examples, see Event patterns.
Click Next Step after configuring the event pattern.
Step 3: Configure event targets
In the Configure Targets step, add one or more event targets. Each target defines a downstream service that receives matched events.
Each event rule supports a maximum of five event targets, and all targets must reside in the same region as the rule.
The following target types are available:
| Target type | Description |
|---|---|
| Function Compute | Process events with serverless functions. Learn more |
| ApsaraMQ for RocketMQ | Store and forward events through message queues. Learn more |
| ApsaraMQ for RabbitMQ | Store and forward events through AMQP-based messaging. Learn more |
| Simple Message Queue (formerly MNS) (SMQ) | Store events in lightweight message queues. Learn more |
| EventBridge | Filter and transform events before forwarding to another event bus. Learn more |
| HTTP gateway | Send events to an HTTP endpoint for custom processing |
| HTTPS gateway | Send events to an HTTPS endpoint for custom processing |
| Direct Mail | Deliver event notifications by email. Learn more |
| DingTalk | Send event notifications through DingTalk messages |
| ApsaraDB RDS for MySQL | Store and forward events to a managed MySQL database. Learn more |
| Self-managed MySQL database | Store and forward events to your own MySQL database |
To reshape event data before delivery, select an event transformation method. For details, see Event transformation.
Click Create to finish.
View event rule details
On the Event Rules page, find the rule and click Details in the Operations column.
The Rule Detail page shows the rule's basic information, event pattern, and configured event targets.
Modify an event rule
Modify event targets
On the Event Rules page, find the rule and click Edit Targets in the Operations column.
On the Edit Rule page, update the event target configurations.
Click OK.
Modify the event pattern
On the Event Rules page, find the rule and click Edit Pattern in the Operations column.
On the Edit Rule page, update the Event Source and Pattern Content parameters.
Click OK.
Disable, enable, or delete an event rule
Disable an event rule
Disabling an event rule may cause dependent services to become unavailable.
On the Event Rules page, find the rule and choose More > Disable in the Operations column.
In the Note message, click OK.
In the Verify Account Security dialog box, click Obtain Verification Code, enter the code in the Verification Code field, and then click OK.
Enable an event rule
On the Event Rules page, find the rule and choose More > Enable in the Operations column.
In the Note message, click OK.
Delete an event rule
Deleting an event rule is irreversible. The data in the event rule cannot be restored.
On the Event Rules page, find the rule and choose More > Delete in the Operations column.
In the Note message, click OK.
In the Verify Account Security dialog box, click Obtain Verification Code, enter the code in the Verification Code field, and then click OK.
What to do next
After creating an event rule:
Refine the event pattern: If the rule captures too many or too few events, modify the event pattern to adjust the filter criteria. See Event patterns.
Transform events: Apply event transformation to reshape event payloads before they reach the target. See Event transformation.
Add more targets: Add up to five event targets per rule to fan out events across multiple services.