You can use the data forwarding feature of the rules engine to forward data to Tablestore.
Prerequisites
- An IoT Platform instance whose data can be forwarded to Tablestore is created in a region that supports data forwarding to Tablestore.
Supported instances Supported regions Enterprise Edition instances: Standard and Video - China (Shanghai)
- Japan (Tokyo)
Public instances - China (Shanghai)
- Singapore
- Japan (Tokyo)
- Germany (Frankfurt)
- US (Silicon Valley) and US (Virginia)
- A Tablestore instance and a table that is used to receive data are created. For more information, see the Tablestore documentation.
Important If you use an IoT Platform instance of Enterprise Edition, the region in which the Tablestore instance is deployed must be the same as the region in which the IoT Platform instance resides.
- A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure a data forwarding rule.
In this example, the following SQL statement is defined in the data forwarding rule:
SELECT items.temperature.value as temperature, items.humidity.value as humidity,deviceName() as deviceName FROM "/sys/a1ktuxe****/BZoyHO***/thing/event/property/post"
Usage notes
You can also use the new version of the data forwarding feature to forward data to Tablestore. For more information about how to use the new version of the data forwarding feature, see Forward data to OTS instances of the Wide Column model.
You can also use the new version of the data forwarding feature to forward data to Tablestore instances of the TimeSeries model. For more information, see Forward data to OTS instances of the TimeSeries model.
Procedure
- Log on to the IoT Platform console.
- On the Overview page, find the instance that you want to manage and click the instance name to go to the Instance Details page.
Important Enterprise Edition instances are available in the China (Shanghai) and Japan (Tokyo) regions. If the Enterprise Edition instances are unavailable in the region that you select, skip this step.
- In the left-side navigation pane, choose .
- Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
Important If the new version of the Data Forwarding page is displayed, click Back to Previous Version in the upper-right corner, and then click View in the Actions column of the rule that you want to manage.
- In the Forward Data section, click Add Operation.
- In the Add Operation dialog box, follow the on-screen instructions to configure parameters and click OK.
Note You can forward only data in the JSON format.
Parameter Description Operation Select Store Data to Tablestore. Region Select the region where your Tablestore instance is deployed. Instance Select a Tablestore instance. You can click Create Instance to go to the Tablestore console and create a Tablestore instance. For more information, see the Tablestore documentation.
Data Table Select a Tablestore table that is used to receive data. You can click Create Data Table to go to the Tablestore console and create a Tablestore table.
Primary Key Configure the primary key of the table. You must set this value to a field value that is specified in the SELECT statement in the data forwarding rule. When data is forwarded, this value is saved as the value of the primary key. Note- You can configure this parameter in the
${}
format. For example, you can set this parameter to ${deviceName}. ${deviceName} specifies that the value of the primary key is the value of thedeviceName
parameter in a message. - If the primary key corresponds to an auto-increment column, you do not need to configure the primary key. Tablestore automatically generates values for the primary key column. By default, the value of an auto-increment primary key column is set to
AUTO_INCREMENT
. You cannot modify the value.For information about auto-increment primary key columns, see Auto-increment of primary key columns.
Role Authorize IoT Platform to write data to Tablestore. If no RAM roles exist, click Create RAM Role to go to the Resource Access Management (RAM) console, create a RAM role, and then grant permissions to the RAM role. For more information, see Create a RAM role.
- You can configure this parameter in the
- Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.
- Perform a test.