Creating an Events Rule
Create a rule in Events to create automation based on the state changes of resources throughout your tenancy.
- Open the navigation menu and click Observability & Management. Under Events Service, click Rules.
Under List Scope, select a compartment you have permission to work in.
Events compares the rules you create in this compartment to event messages emitted from resources in this compartment and any child compartments.
Click Create Rule.
In the Create Rule panel, provide a friendly name for the rule and a description of what the rule does. You can change both values later. Avoid entering confidential information.
In the Rule Conditions area, you can define filters based on event types, attributes, and tags to limit the events that trigger actions. See Matching Events with Filters. Complete the following steps to define these filters.Tip
To match all events, leave this field blank. Skip to step 8.
To filter events by add an event type, follow these steps.
- For Condition, select Event Type.
- Select a service.
- In Event Type, select one or more types of events for this the service.
- To add event types for a different service, click + Another Condition and select Event Type repeat the preceding steps to add event types for a different service.
To further filter event types by using attributes, follow these steps. You must create an event type condition before you can add an attribute.
- After adding an event type, click + Another Condition.
- For Condition, select Attribute.
- Select an attribute.
- (Optional) In Attribute Values, select or enter values for the attribute.
To filter events by using tags, follow these steps.
Filter tags help you to hone automation by targeting only resources that contain a particular tag. If you want to use tags to organize your rules, use resource tags instead. For more information, see Managing Tags for Rules.
- For Condition, select Filter Tag
- Select a tag namespace.
To specify a free-form tag, select None (add a free-form tag).
- Select a tag key.
- (Optional) Enter a tag value.
- To add another tag, click + Another Condition and repeat the preceding steps.
To validate the rule based on the conditions that you specified, click Validate Rule and follow these steps in the Validate Rule panel.
You can evaluate a rule against one event type at a time. To test different event types, repeat these steps as necessary.
- In Service Name, select a service.
- In Event Type, select an event type.
An example event appears based on your selections you made. Edit the values in the event to match the values for any attributes and tags that you added to your rule. For more information, see Contents of an Event Message.
- Click Check if Example Event Matches Rule.
- If the rule doesn't match, use the rule editor to make the following changes as needed:
- Add or remove event types
- Add or remove values or attributes
- Add or remove tags
For more information, see Matching Events with Filters.
- Click Cancel.
To view reference (example) events, click the View example events (JSON) and follow these stes in the View Example Events panel.
- For Action Type, specify the resource to trigger when the filter finds a match.
- If you select Notifications, select the compartment where the topic that you want to use is located, and then select the topic.
- If you select Streaming, select the compartment where the stream that you want to use is located, and then select the stream.
- If you select Functions, select the compartment where the function that you want to use is located, select the function application, and then select the function.
To add another action, click + Another Action.
- Click Create Rule.
Run the CreateRule operation to create a rule.