You can use the data forwarding feature of the rules engine to forward processed data to ApsaraDB RDS instances for storage. This article describes how to forward data to a destination.

Prerequisites

  • An ApsaraDB RDS instance is created in the region where your IoT Platform instance resides. The database engine of the instance must be MySQL or Microsoft SQL Server and the network type of the instance must be VPC. A database and table are created. For more information about how to use ApsaraDB RDS, see the ApsaraDB RDS documentation.
  • 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.

Limits

  • Data forwarding is supported between IoT Platform instances and ApsaraDB RDS instances that reside in the same region. For example, you can forward the data of an IoT Platform instance in the China (Shanghai) region to an ApsaraDB RDS table that resides only in the China (Shanghai) region.
  • You can forward data to ApsaraDB RDS instances that resides only in VPCs.
  • You can forward data to MySQL and SQL Server instances.
  • Data forwarding is supported between standard databases and privileged databases.
  • You can forward data only in the JSON format.

Procedure

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Rules > Data Forwarding.
  3. Click View next to the required rule. The Data Forwarding Rule page appears.
  4. In the Data Forwarding section, click Add Operation.
  5. In the Add Operation dialog box, select Save to RDS in the Select Operation field. Set the parameters and click OK.
    Parameter Description
    Select Operation Select Save to RDS.
    Select a region Select the region where your IoT Platform instance resides.
    RDS instance Select the ApsaraDB RDS instance.
    Database management Enter the database name.
    Note If you use a privileged database, you must enter a database name.
    Account Enter the account of the ApsaraDB RDS instance. This account must have the read and write permissions on the database. Otherwise, the rules engine cannot write data to the ApsaraDB RDS instance.
    Note After the rules engine obtains the account, the rules engine writes only the data that matches the specified rule to the database. No extra operations are performed.
    Password Enter the password that is used to log on to the ApsaraDB RDS instance.
    Table Name Enter the name of the table that is created in the database. The rules engine writes data to the table.
    Key Enter the name of the field in the table. The rules engine writes data to the field.
    Value Enter the value of the field in the topic of the SQL statement as the value of the key.
    Note
    • The data type of the key must be the same as the data type of the value. Otherwise, you may fail to save this parameter.
    • You can enter a variable, for example, ${deviceName}.
    Role Authorize IoT Platform to write data to ApsaraDB RDS.
  6. Go to the Data Forwarding page, find the required rule, and then click Start in the Actions column of the rule.
  7. Log on to the ApsaraDB RDS console. On the Data Security page, configure a whitelist or view whitelists. After you set the parameters, the rules engine adds the following IP addresses to the ApsaraDB RDS whitelist. Then, the rules engine can communicate with ApsaraDB RDS. If one of the following IP addresses is not displayed in the whitelist, you must manually add the IP address.
    • China (Shanghai): 100.104.53.192/26,100.104.148.64/26,100.104.6.192/26,100.104.143.128/26,100.104.76.0/24,100.104.73.128/26,100.104.200.64/26,100.104.40.64/26,100.104.3.0/26,100.104.29.128/26,100.104.121.0/26,100.104.84.64/26
    • Singapore (Singapore): 100.104.106.0/24
    • US (Silicon Valley): 100.104.8.0/24
    • US (Virginia): 100.104.133.64/26
    • Germany (Frankfurt): 100.104.160.192/26
    • Japan (Tokyo): 100.104.160.192/26
    ApsaraDB RDS database