You can use the data forwarding feature of the rules engine to forward data to Tablestore.

Prerequisites

  • A Tablestore instance and a table that is used to receive data are created. For more information about how to use Tablestore, see the Tablestore documentation.
  • A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure data forwarding rules.
    In this example, the following SQL statement is defined:
    SELECT deviceName as deviceName, items.PM25.value as PM25, items.WorkMode.value as workmode 
    FROM "/sys/a1ktuxe****/aircleaner/event/property/post" WHERE

Procedure

  1. In the Add Operation dialog box, select Save to Tablestore. Set the required parameters as prompted and click OK.
    Note Only JSON-formatted data can be forwarded.
    Tablestore
    Parameter Description
    Select Operation Select Save to Tablestore.
    Region Select a region where Tablestore runs.
    Instance Select a Tablestore instance.

    To create an instance in the Tablestore console, click Create Instance. For more information, see the Tablestore documentation.

    Table Select a Tablestore table that is used to receive data.

    To create a table in the Tablestore console, click Create Table.

    Primary Key Specify a value for the primary key of the table. You must set this value to a field value that is specified in the SELECT statement of the rule. When data is forwarded, this value is saved as the value of the primary key.
    Note
    • You can set this parameter in the ${} format. For example, ${deviceName} indicates that the value of the primary key is the value of the deviceName parameter in a message.
    • If the primary key corresponds to an auto-increment column, you do not need to specify a value for the primary key. Tablestore generates a value for this primary key column. By default, the value of an auto-increment primary key is set to AUTO_INCREMENT. You cannot modify the value.

      For more information about auto-increment primary keys, see Auto-increment of primary key columns.

    Role Authorize IoT Platform to write data to Tablestore.
  2. Run a test.
    1. Log on to the IoT Platform console.
    2. In the left-side navigation pane, choose Maintenance > Device Simulation.
    3. Select the required device and choose Upstream Debug > Properties > Start Device Simulation.
    4. Set the required test data and click Send Command to push data.
      Device simulation
    5. After the data is pushed, log on to the Tablestore console. Go to the Data Editor page of the table that is used to receive data and check whether the specified data is received.
      Data management