All Products
Search
Document Center

IoT Platform:Forward data to OTS

Last Updated:Oct 30, 2023

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

Prerequisites

  • An IoT Platform instance whose data can be forwarded to OTS is created in a region that supports data forwarding to OTS. For more information about the regions that support data forwarding, see Regions.

  • An OTS instance and a table that is used to receive data are created. For more information, see the OTS documentation.

    Important

    If you use an IoT Platform instance of Enterprise Edition, the region where the OTS instance resides must be the same as the region where 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 use the new version or the previous version of the data forwarding feature to forward data to OTS. 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 OTS instances of the TimeSeries model. For more information, see Forward data to OTS instances of the TimeSeries model.

Procedure

  1. Log on to the IoT Platform console.
  2. On the Overview page, click All environment. On the All environment tab, find the instance that you want to manage and click the instance ID or instance name.

  3. In the left-side navigation pane, choose Message Forwarding > Data Forwarding.
  4. 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.
  5. In the Forward Data section, click Add Operation.
  6. In the Add Operation dialog box, configure the parameters as prompted and click OK. The following table describes the parameters.

    Note

    You can forward only data in the JSON format.

    表格存储

    Parameter

    Description

    Operation

    Select Store Data to Tablestore.

    Region

    Select the region where your OTS instance resides.

    Instance Type

    Select an OTS instance.

    You can click Create Instance to go to the OTS console and create an OTS instance. For more information, see the OTS documentation.

    Table

    Select an OTS table that is used to receive data.

    You can click Create Data Table to go to the OTS console and create an OTS 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 the deviceName parameter in a message.

    • If the primary key corresponds to an auto-increment column, you do not need to configure the primary key. OTS automatically generates values for the primary key column. By default, the value of an auto-increment primary key is set to AUTO_INCREMENT. You cannot modify the value.

      For information about auto-increment primary key columns, see Configure an auto-increment primary key column.

    Role

    Authorize IoT Platform to write data to OTS.

    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.

  7. Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.
  8. Perform a test.

    1. Log on to the IoT Platform console.

    2. In the left-side navigation pane, choose Device Simulation.

    3. Select the device that you want to test, and choose Upstream Debug > Properties > Start Device Simulation.

    4. Below Default Module, specify test data and click Send Command.

      设备模拟器
    5. After the data is pushed, log on to the OTS console and go to the Data Editor page of the table that is used to receive data and check whether the specified data is received.

      数据管理