All Products
Search
Document Center

IoT Platform:Forward data to TSDB

Last Updated:Jun 16, 2026

Configure data forwarding rules to forward processed data to Time Series Database (TSDB) for storage. The following example uses a Thing Specification Language (TSL) communication topic as the source topic to demonstrate the complete forwarding process.

Prerequisites

  • An IoT Platform instance whose data can be forwarded to TSDB is created in a region that supports data forwarding to TSDB. For more information, see Feature availability by region.

  • A data source named DataSource is created and a TSL communication topic is added to the data source. For more information, see Add a data source.

  • A TSDB instance is created in a virtual private cloud (VPC) in the Japan (Tokyo) region. For more information, see the Time Series Database (TSDB) documentation.

Background information

After you configure the data destination, IoT Platform automatically completes the following configurations to forward device data from the rules engine to Time Series Database (TSDB).

  • IoT Platform uses two IP addresses from the virtual switch where the TSDB instance is located. The IPv4 CIDR block of the virtual switch is added to the whitelist of the TSDB instance.
  • A managed security group is created in the VPC where the TSDB instance is located. The security group name starts with sg-nsm- by default.

In this example, the following data is written to TSDB:

  • timestamp: Use the timestamp() function to obtain the timestamp of the data reported by the device.
  • tag: Use the deviceName() function to obtain the device name and write it to the tag {"deviceName":deviceName()}.
  • metric: Use the JSONPath method to obtain the values of the TSL model properties Temperature and Humidity reported by the device. These values are then written to the time series data as temperature and humidity metrics.

Limits

  • Data can only be forwarded within the same region. For example, data from an IoT Platform instance in Japan (Tokyo) can only be forwarded to a TSDB instance in Japan (Tokyo).
  • Data can only be forwarded to TSDB instances in a virtual private cloud (VPC).
  • Only data in JSON format can be forwarded.
  • In a forwarded message, all fields are written to the Time Series Database as metrics, except for the fields configured as the timestamp and tag values. The metric data type supports numeric values and strings. Other data types cause the write operation to fail.

Usage notes

You can also use the new or previous version of the data forwarding feature to forward data to TSDB. For more information, see UForward data to TSDB.

Create a data destination

  1. Log on to the IoT Platform console.

  2. On the Overview page, 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. On the Data Forwarding page, click Go to New Version in the upper-right corner.

    Note

    If you have performed this operation before, you are automatically redirected to the new version of the Data Forwarding page.

  5. Click the Data destination tab, and then click Create data destination.

  6. In the Create Data Destination dialog box, enter a data destination name. In this example, DataPurpose is used. Configure the parameters and click OK.

    Parameter

    Description

    Operation

    Select Store Data to TSDB.

    Region

    The region of your IoT Platform instance.

    TSDB Instance

    The TSDB instance that you created in a VPC.

    metric Data Type

    The data type of the metric parameter. Valid values: Numeric Type and String.

    You can click the 帮助 icon for help.

    Role

    Authorize IoT Platform to write data to TSDB.

Configure and start a parser

  1. Create a parser, such as DataParser. For more information, see Step 1: Create a parser.

  2. On the Resolver Details page, associate the data source.

    1. In the configuration wizard, under Data Source, click Associate Data Source.

    2. In the dialog box, select DataSource from the Data Source drop-down list and click OK.

  3. On the Resolver Details page, you can associate data destinations.

    1. In the configuration wizard, click Data Destination. Then, in the upper-right corner of the Data Destination list, click Associate Data Destination.

    2. In the dialog box that appears, from the Data Destination drop-down list, select DataPurpose and click OK.

    3. In the data destination list, find the Data Destination ID and record it. For example, 1000.

      You will need this Data Destination ID in the parsing script.

  4. On the parser details page, click the Parser Script tab.

  5. In the code editor, enter a script. For more information about how to modify a script, see Script syntax.

    For more information about function parameters, see Function list.

    // Use the payload() function to obtain the data that is submitted by devices and convert the data to JSON-formatted data. 
    var data = payload("json");
    // Filter the submitted temperature and humidity values. 
    var h = data.items.Humidity.value;
    var t = data.items.Temperature.value;
    // Forward submitted TSL data. 
    writeTsdb(1000,timestamp(),"temperature", t , {"deviceName":deviceName()});
    writeTsdb(1000,timestamp(),"humidity", h , {"deviceName":deviceName()});
  6. Click Debugging. In the dialog box that appears, select a product and a device, specify a topic, and then enter payload data to check whether the script runs as expected.

    The following figure shows the parameters.示例

    The following result indicates that the script runs as expected.

    调试结果

  7. Click Publish.

  8. Return to the Resolver tab on the Data Forwarding page and click Start for the DataParser resolver.