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
-
You have created a wide table or a time series table.
Step 1: Add a custom event source
-
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 target custom event bus.
-
In the left-side navigation pane, click Event Sources, and then click Add Event Source.
-
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
-
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 target event bus.
-
In the left-side navigation pane, click Event Rules, and then click Create Rule.
-
In the Create Rule panel, complete the following steps.
-
On the Configure Basic Info tab, enter a Name and Description, and then click Next.
-
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.
-
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.nameSet 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:
-
Internet
-
VPC: If you select this option, you must create a VPC, a vSwitch, and a security group in advance.
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
JsonPathrules. 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
JsonPathrules 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
JSONPathexpression.Value: You can specify only a
JSONPathexpression. 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:00format. 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:
-
Internet
-
VPC: If you select this option, you must create a VPC, a vSwitch, and a security group in advance.
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
-
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, find the target event bus and click Publish Event in the Operations column.
NoteOnly custom event buses support publishing events from the console.
-
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.
-
Log on to the Table Store console. In the left-side navigation pane, click All Instances.
-
On the All Instances page, click the name of the target instance.
-
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.
-
On the Data Management tab of the target data table, view the inserted data.