You can use the data forwarding feature of the rules engine to forward processed data to ApsaraDB RDS instances for storage.

Prerequisites

  • An ApsaraDB RDS instance is created in the region where the related 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 data forwarding rules.

Limits

  • Data forwarding is supported between IoT Platform instances and ApsaraDB RDS instances that reside only 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 required parameters as prompted and click OK.
    Parameter Description
    Select Operation Select Save to RDS.
    Region Select a region where the related IoT Platform instance resides.
    RDS instance Select an ApsaraDB RDS instance.
    Database Enter a database name.
    Note If you use a privileged database, you must enter a database name.
    Account Enter the username of an account for 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, only rules that match the specified rule are written to the database. No extra operations are performed.
    Password The password that is used to log on to the ApsaraDB RDS instance.
    Table Name Enter the name of a table that is created in the database. The rules engine writes data to the table.
    Key Enter the name of a field in the table. The rules engine writes data to the field.
    Value Enter the value of a field in the topic of the SQL statement for data processing 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 required parameters, the rules engine adds the following IP addresses to an ApsaraDB RDS whitelist. Then, the rules engine can communicate with ApsaraDB RDS. If one of these IP addresses is not added, you need to add the IP address.
    • China (Shanghai): 100.104.123.0/24
    • 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