All Products
Search
Document Center

Create an event-trigger O&M task

Last Updated: Jun 11, 2020

Cloud service events are status changes of cloud service resources. For example, an Elastic Compute Service (ECS) instance is restarted abnormally or released, a snapshot is created for an ECS instance, or O&M operations will be performed on an ECS instance. For more information, see Event monitoring overview. Operation Orchestration Service (OOS) supports O&M tasks triggered by cloud service events. In an event-triggered O&M task, you can specify a template to be executed when the specified event occurs. An event-triggered O&M task keeps running to listen to the specified cloud service events until you cancel the task.

To create an event-triggered O&M task, follow these steps:

  1. Set a trigger rule to monitor the cloud service event that you concern.
  2. Select a template to be executed.
  3. Set parameters for executing the template.

Set a trigger rule

Set a trigger rule to monitor the cloud service event that you concern. The following table describes the parameters for a trigger rule.

Parameter Required Description
Product Yes The service to monitor. Select a service from the drop-down list.
Event Name Yes The name of the cloud service event. You can select multiple events. For more information about the valid values, see Cloud service events.
Region No The region of the event resources. You can select multiple regions. For more information about the valid values, see Regions and zones.
Event Severity No The severity of the event. Valid values: Critical, Warning, and Information.
Event Details Filtering Rule No The JSON text used to filter the details of cloud service events.

oos

Rules for filtering event details

Details of cloud service events are described in JSON texts. Fields in event details vary with the event type. You can filter event details based on the fields. Take the notifications for ECS instance status changes as an example. The event details indicated by the content field in the event message body are in the following format:

  1. {
  2. "resourceId": "i-bp1ecr********5go2go",
  3. "resourceType": "ALIYUN::ECS::Instance",
  4. "state": "Running"
  5. }

The resourceId field in the event details indicates the ID of the ECS instance whose status was changed. An ECS instance can be in the pending, starting, running, stopping, stopped, or deleted state.

Rules for filtering event details are also described in JSON texts. In such a rule, use a key in the event details and set the value to the corresponding value or values in the event details.For example, if you want to configure an O&M task that is triggered when an instance is stopped, set the rule as follows:

  1. {
  2. "state": "Stopped"
  3. }

If you want to configure an O&M task that is triggered when the i-abcde instance is stopped or released, set the rule as follows:

  1. {
  2. "resourceId": "i-abcde",
  3. "state": ["Stopped", "Deleted"]
  4. }

oosA sample text of event details is shown on the right of the Event Details Filtering Rule field for reference.

Select a template to be executed

Select a template to be executed when the specified cloud service event occurs.

oos

Set parameters for executing the template

In this step, select Extract Value from Message Body or Fixed Value. If you select Fixed Value, the template will be executed based the parameter values that you set. If you select Extract Value from Message Body, you can use jQuery expressions to extract values from event message bodies for executing the template.

To extract values from event message bodies, use jQuery expressions in the $.Parameter name format.Take the message body of notifications for ECS instance status changes as an example. You can use the $.content.resourceId expression to extract the value of the resourceId parameter,and use the $.regionId expression to extract the value of the regionId parameter.

The following table describes the parameters that can be extracted from all event message bodies.

Expression Description Example
$.id The ID of the event. 9435EAD6-3CF6-4494-8F7A-3A**77
$.eventTime The time when the event occurred (UTC+8). 20181226T220114.058+0800
$.level The severity of the event. Valid values: INFO, WARN, and CRITICAL. INFO
$.name The name of the event. Instance:StateChange
$.regionId The ID of the region where the event occurred. For more information about the valid values, see Regions and zones. cn-hangzhou
$.product The name of the cloud service. ECS
$.resourceId The Alibaba Cloud Resource Name (ARN) of the resource. acs:ecs:cn-hangzhou:169070**30:instance/i-bp1ecr**5go2go
$.userId The ID of the Alibaba Cloud account. 169070**30
$.content.fieldName The dimension of the event. N/A

The following figure shows an example of extracting values from an alert message body.oos

You can also set fixed parameter values for executing the template. The method is similar to that for common templates.