All Products
Search
Document Center

IoT Platform:Forward data to Tablestore

Last Updated:Apr 25, 2026

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

Prerequisites

Create a data table

  1. Log on to the Tablestore console. In the top navigation bar, select the Japan (Tokyo) region.

    Important

    The Tablestore instance must be in the same region as the Enterprise instance.

  2. Click Create Instance. In the Create Instance dialog box, enter an instance name, for example, IoTDataStore, use the default values for the other parameters, and then click OK.

    For more information, see Create a Tablestore instance.

  3. On the Instance Details tab of the IoTDataStore instance, click Create Table. Enter a name for the data table, such as iot_data, and add two primary keys: deviceName (String) and timestamp (Integer). For more information, see Create a data table.

Configure a data forwarding rule

  1. In the left-side navigation pane of the IoT Test Environment instance, choose Rules Engine > Data Forwarding.

  2. On the Data Forwarding page, click Create Rule.

    Important

    If the Data Forwarding page of the latest version appears, click Back to Previous Version in the upper-right corner of the page. When the Data Forwarding page of the previous version appears, click Create Rule.

  3. In the Create Data Forwarding Rule dialog box, enter a rule name, such as ThermostatDataForwarding, set Data Format to JSON, and click OK.

  4. After you create the rule, the Data Forwarding Rules page appears. On this page, write an SQL statement to process message data and set up a data forwarding destination.

    The page has two sections: Process Data and Forward Data. The Process Data section contains the rule query statement and a Write SQL button, while the Forward Data section lists data destinations and has an Add Operation button.

    1. Click Write SQL. In the dialog box that appears, enter the fields for the SELECT clause. For the topic data source, select TSL Data Reporting for Data Type, Home Thermostat for Product, Device1 for Device, Default Module for Module, and thing/event/property/post for topic. Click OK.

      The SELECT clause for this example is as follows:

      items.temperature.value as temperature, items.humidity.value as humidity,deviceName() as deviceName,timestamp() as time

      For more information about how to write SQL queries, see SQL expressions and Functions.

      The Rule Query Statement section at the top of the dialog box displays the complete SQL statement. The Topic section at the bottom shows the selected parameters.

    2. In the Forward Data section, click Add Operation to set the iot_data data table as the data forwarding destination. For more information, see Forward data to Tablestore.

      In the Edit Operation dialog box, select Forward data to Tablestore for Operation. Select China (Shanghai) for Region, IoTDataStore for Instance, and iot_data for Data Table. Under Primary Key, set the value for the deviceName key to ${deviceName} and the value for the timestamp key to ${time}. Select AliyunIOTAccessingOTSRole for Role, and click OK.国际站流转数据目的

  5. After you complete the settings, return to the Data Forwarding page. Find the rule that you created and click Start in the Actions column. Once started, the rule forwards data as configured.

    After the virtual device reports data, you can view the data in the iot_data data table in Tablestore in real time.

    The data table contains four fields: deviceName (primary key), timestamp (primary key), humidity, and temperature. Each row represents a temperature and humidity reading reported by the device.

    You can also view the complete forwarding logs in Log Service for your Enterprise Edition instance to troubleshoot forwarding issues.

    On the Cloud Run Logs tab, select the corresponding Product to view log entries. The log entries include information such as Time, TraceID, MessageId, Message Content, DeviceName, Business Type, Action, Content, and Status. You can track the data flow by filtering by Business Type, such as Rules Engine or TSL. A Status of 200 indicates successful data processing.

Next steps

Subscribe to device messages on the server side