Route events to Table Store

更新时间:
复制 MD 格式

You can use an event rule to filter events and route them to Table Store. This topic uses a custom event as an example to describe the prerequisites, the steps to route the events, and how to verify the result.

Prerequisites

Step 1: Add a custom event source

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

  2. In the top navigation bar, select a region. On the Event Buses page, click the name of the target custom event bus.

  3. In the left-side navigation pane, click Event Sources, and then click Add Event Source.

  4. In the Add Custom Event Source panel, enter a Name and Description, select Event Provider for Event Provider, and then click OK.

Step 2: Create an event rule

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

  2. In the top navigation bar, select a region. On the Event Buses page, click the name of the target event bus.

  3. In the left-side navigation pane, click Event Rules, and then click Create Rule.

  4. In the Create Rule panel, complete the following steps.

    1. On the Configure Basic Info tab, enter a Name and Description, and then click Next.

    2. On the Configure Event Pattern tab, for Event Source Type, select Custom Event Sources, select the event source that you created, and then click Next.

    3. On the Configure Targets tab, configure the following parameters, and then click Create.

      Wide table

      Parameter

      Example

      Description

      Service Type

      Table Store

      Select Tablestore from the drop-down list.

      Instance Name

      test_eb

      Select the instance that you created from the drop-down list.

      Destination Table

      test

      Select the wide table that you created from the drop-down list.

      Primary Key

      $.data.name

      Set the primary key value. You can extract the value from the event data by using a JSONPath expression.

      Attribute Column

      None

      Optional. To add an attribute column, click Add Attribute Column.

      Write Mode

      put

      The following write modes are supported:

      • put: If two data entries have the same primary key, the new data overwrites the old data.

      • update: If a row with the same primary key exists, this mode updates only the specified columns, leaving other existing columns unchanged.

      • delete: Deletes the row for the specified primary key.

      Network Configuration

      Internet

      The following network types are supported:

      Retry Policy and Dead-letter Queue

      None

      For information about how to configure these parameters, see Retry policies and dead-letter queues.

      Time series table

      Parameter

      Example

      Description

      Service Type

      Table Store

      Select Tablestore from the drop-down list.

      Instance Name

      test_eb

      Select the instance that you created from the drop-down list.

      Destination Table

      test1

      Select the time series table that you created from the drop-down list.

      Metric Name

      default

      You can specify a metric name in one of the following ways:

      • Fixed Value: Enter a constant as the metric name. The default value is default.

      • Partial Event: Enter the metric name to insert. You can use custom JsonPath rules. For example, $.data.

      Data Source

      default

      (Optional) You can specify a data source in one of the following ways:

      • Fixed Value: Enter a constant as the data source. The default value is default.

      • Partial Event: Enter the data source to insert. You can use JsonPath rules to customize it. For example, $.data.

      Tag

      None

      (Optional) Configure the Name and Value of the tag:

      Name: You can specify a constant or a JSONPath expression.

      Value: You can specify only a JSONPath expression. For example, $.data.name.

      Attribute Column

      test

      You need to configure the following parameters:

      • Attribute column name: You can enter constants and JsonPath. For example: $.data, $.id.

      • Type: The supported types are String, Integer, Binary, Float, and Boolean.

      • Value: You can extract the value from event data by using a JSONPath expression. For example, $.data.name.

      • Storage Format: The supported formats are the default format and JSON format.

      Time

      2025-01-05 14:30:00

      • A timestamp in seconds. The value can be an integer or a float.

      • A time string in the 2023-04-05 14:30:00 format. The value must be a string.

      Time Zone

      Asia/China (UTC+8:00)

      Select the destination time zone from the drop-down list.

      Network Configuration

      Internet

      The following network types are supported:

      Retry Policy and Dead-letter Queue

      None

      For information about how to configure these parameters, see Retry policies and dead-letter queues.

Step 3: Publish an event

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

  2. In the top navigation bar, select a region.

  3. On the Event Buses page, find the target event bus and click Publish Event in the Operations column.

    Note

    Only custom event buses support publishing events from the console.

  4. In the Publish Event to Custom Event Bus {name} panel, select your custom event source from the Custom Event Source drop-down list, enter the event content in the Event Body code editor, and then click OK.

    For more information about event parameters, see Event structure.

Verify the results

View the data in the destination data table in the Table Store console.

  1. Log on to the Table Store console. In the left-side navigation pane, click All Instances.

  2. On the All Instances page, click the name of the target instance.

  3. On the Instance Management page, on the Instance Details tab, find the Instance Usage Information section, and then click the target data table.

    On the Data Table List tab, verify that the data table test is listed.

  4. On the Data Management tab of the target data table, view the inserted data.