All Products
Search
Document Center

DataWorks:Enable event message subscription

Last Updated:Oct 23, 2024

The OpenEvent module of DataWorks Open Platform allows you to subscribe to and consume event messages by using EventBridge. After you create a custom bus in EventBridge, you must configure an event distribution channel in DataWorks before you can create event rules and publish events in EventBridge. This topic describes how to enable the event message subscription feature in DataWorks and configure a custom bus in EventBridge.

Prerequisites

  • DataWorks Enterprise Edition is activated in one of the following regions:

    China (Beijing), China (Hangzhou), China (Shenzhen), China (Shanghai), China (Zhangjiakou), China (Chengdu), US (Silicon Valley), US (Virginia), Germany (Frankfurt), Japan (Tokyo), China (Hong Kong), and Singapore. The OpenEvent module of DataWorks Open Platform is available only for DataWorks Enterprise Edition users in these regions.

  • EventBridge is activated. The OpenEvent module of DataWorks Open Platform relies on the message distribution capability of EventBridge to subscribe to and consume messages. Therefore, you must activate EventBridge. For more information about EventBridge, see What is EventBridge?

Precautions

How it works

DataWorks supports subscription to the messages of status change events of key processes. In the OpenEvent module of DataWorks Open Platform, you can configure the mapping between a DataWorks workspace and an EventBridge event bus. This way, all open messages in the DataWorks workspace can be pushed to the specified EventBridge event bus. Then, you can go to the EventBridge console for further message management. For example, you can search for the event messages that you want to consume from all event messages that are sent from DataWorks to EventBridge and specify the type of service that you want to use to receive the event messages or how the event messages are consumed.

image
Note

Messages generated by the operations performed on tenant-level services are automatically pushed to the default event bus of EventBridge.

DataWorks

In DataWorks, you must configure an event distribution channel to push event messages to an EventBridge event bus. You must perform the following steps in DataWorks to authorize DataWorks to access EventBridge and specify the EventBridge event bus used to receive the open messages pushed to EventBridge from a DataWorks workspace.

Step 1: Authorize DataWorks to access EventBridge

The first time you use the OpenEvent module, you must use an Alibaba Cloud account or a RAM user to which the AliyunDataWorksFullAccess policy is attached to perform the following steps to enable DataWorks to access EventBridge:

  1. Go to the Open Platform page.

    Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose More > Open Platform. The Developer Backend tab appears.

  2. Go to the OpenEvent page.

    In the left-side navigation pane of the Developer Backend page, click OpenEvent. The OpenEvent page appears.

  3. Authorize DataWorks to access your EventBridge resources.

    The first time you use EventBridge, the Authorize Now button is displayed in the Event Message Subscription by Using EventBridge section. To use EventBridge, follow the on-screen instructions to authorize DataWorks to access your EventBridge resources. After the authorization is complete, the service-linked role AliyunServiceRoleForDataWorksOpenPlatform is created. You can log on to the RAM console and choose Identities > Roles in the left-side navigation pane to view the service-linked role. For more information about the service-linked role, see the View the permissions of the AliyunServiceRoleForDataWorksOpenPlatform role section in the "Appendix: DataWorks service-linked role" topic.

Step 2: Configure an event distribution channel

An event distribution channel maps a DataWorks workspace to an EventBridge event bus. You can use an event distribution channel to push all open messages in a DataWorks workspace to an EventBridge event bus.

  1. Go to the OpenEvent page.

    In the left-side navigation pane of the Developer Backend page, click OpenEvent. The OpenEvent page appears.

  2. Configure an event distribution channel.

    In the Event Message Subscription by Using EventBridge section, click Add Event Distribution Channel. In the Add Event Distribution Channel dialog box, configure the Workspace for Distribution of Event Messages and Specify Custom Event Bus in EventBridge for Distribution of Event Messages parameters.

    Note
    • If no event bus is available in EventBridge, you can click Create Custom Event Bus in the dialog box to go to the EventBridge console to create a custom event bus. You can also click Quickly Create Custom Event Bus with Same Name as Your Workspace in the dialog box to quickly generate a custom event bus.

    • Messages generated by the operations performed on tenant-level services are automatically pushed to the default event bus of EventBridge. If you want to receive event messages generated by operations performed on tenant-level services, skip this step.

    image

Step 3: Enable the event distribution channel

After you configure the event distribution channel, you can view the created event distribution channel on the OpenEvent page. You can find the created event distribution channel and click Delete, Enable, or Disable in the Actions column to perform the related operation on the event distribution channel.

  • Enable: After you enable the event distribution channel, event messages of the workspace are pushed to the mapped EventBridge event bus.

    In the EventBridge console, you can view all event messages that are pushed from DataWorks to EventBridge, search for the event messages that you want to consume, and specify the type of service that you want to use to receive the event messages or how the event messages are consumed.

  • Disable: After you disable the event distribution channel, event messages of the workspace are no longer pushed to the mapped EventBridge event bus. You cannot receive the event messages by using EventBridge.

  • Delete: After you delete the event distribution channel, event messages of the workspace are no longer pushed to the mapped EventBridge event bus. You cannot receive the event messages by using EventBridge.

After you click Enable in the Actions column of an event distribution channel, the event distribution channel is enabled. Messages that are distributed to the mapped event bus by using the event distribution channel are pushed to the configured event target based on a specific event rule.

EventBridge

After you enable an event distribution channel in DataWorks, DataWorks automatically pushes open messages to the mapped EventBridge event bus. In EventBridge, you must configure a filter to search for the event messages that you want to consume from all event messages that are sent from DataWorks to EventBridge and specify the type of service that you want to use to receive the event messages or how the event messages are consumed.

Step 1: (Optional) Create a custom event bus

If you click Quickly Create Custom Event Bus with Same Name as Your Workspace in Step 2: Configure an event distribution channel to create a custom event bus, directly use the created custom event bus. If you click Create Custom Event Bus, you are redirected to EventBridge to create a custom event bus. In this case, perform the following steps: For more information about EventBridge, see Overview.

  1. Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.

  2. In the upper-right corner of the Event Buses page, click Quickly Create to create a custom event bus. In this topic, a custom event bus named DataWorks2023 is created.

    image

Note
  • In the Create Custom Event Bus panel, after you configure the Name and Description parameters for the custom event bus, you can skip the Event Source, Event Rule, and Event Target steps to quickly create the event bus.

  • Messages generated by the operations performed on tenant-level services are automatically pushed to the default event bus of EventBridge. If you want to receive event messages generated by operations performed on tenant-level services, skip this step.

Step 2: Configure an event rule

After you create the custom event bus, you can manually configure an event rule for the event bus. This way, event messages of DataWorks can be pushed to the corresponding service.

  1. Log on to the EventBridge console.

  2. Configure an event rule.

    In the left-side navigation pane, click Event Buses. On the Event Buses page, find the EventBridge event bus for which you want to configure data filtering and specify the type of service that you want to use to receive event messages, and click Event Rules in the Actions column.

    Configure the basic information

    In the upper-left corner of the page that appears, click Create Rule. In the Configure Basic Info step of the Create Rule panel, configure parameters and click Next Step.image

    • Name: The name of the event rule.

    • Description: The description of the event rule.

    Configure the event pattern

    1. In the Configure Event Pattern step of the Create Rule panel, configure the event pattern to search for the event messages that you want to consume. Sample configurations:

      • Event Source Type: Select Custom Event Source.

      • Event Source: Retain the default value.

      • Pattern Content: Use JSON data to configure the type of an event message. In DataWorks, each event message has a fixed type. You can refer to Development reference: Event messages and formats of event messages to obtain the type of an event message generated by the corresponding operation performed in DataWorks and configure the event message type as the value of the type key in JSON data.

        {
            "source": [
                "acs.dataworks"
            ],
            "type": [
                "dataworks:InstanceStatusChanges:InstanceStatusChanges"
            ]
        }

        image

    2. Debug the event pattern to check whether the pattern meets your expectations.

      After you complete Step 3: Enable the event distribution channel in DataWorks, DataWorks event messages can be sent to EventBridge. On the Event Tracking page of EventBridge, you can find an event and click Event Detail in the Actions column, copy the content in the Event Detail message, and then paste the content in the code editor below Event Pattern Debugging. Then, click Test to check whether the event message type configured in Pattern Content is consistent with the event message type in the code editor.

      • If the event message types are inconsistent, the Match failed. message is displayed after you click Test.

      • If the event message types are consistent, the Match succeeded. The event can be triggered as expected. message is displayed after you click Test.

    Configure the event targets

    Event messages can be pushed not only to self-managed services, but also to other services for consumption. For more information, see Overview.

    image

    Note

    The preceding figure shows that an event message is pushed to a specified HTTPS service. If you want an extension to receive the event message, you must set the Service Type parameter to HTTPS and the URL parameter to the deployment address of the extension.

  3. Click Create. After you create the event rule, you can use EventBridge to distribute and route DataWorks event messages. The event message subscription feature also provides support for the Extensions module of DataWorks Open Platform.

Best practices

Event message subscription by a local service: Best practices for configuring the settings in DataWorks Open Platform to perform a lockdown

Appendix: View pushed event messages

After you enable an event distribution channel in DataWorks, when events are triggered in the workspace configured in the event distribution channel, you can find the event bus that maps to the workspace and view the event messages based on event types on the Event Tracking page of EventBridge. For information about event types, see Development reference: Event messages and formats of event messages.

image