All Products
Search
Document Center

IoT Platform:Configure a Custom Topic Data Store

Last Updated:Oct 31, 2024

Leverage the time series data storage rule feature to forward specific custom topic data to time series storage space. This guide outlines the steps to set up time series storage rules for custom topic data.

Prerequisites

  • Ensure your current instance is a medium or premium enterprise edition and that you have purchased the necessary time series data storage IOPS and space. For more information, see Purchase an Enterprise Edition Instance.

  • The device must have a custom topic added. For more information, see Custom Topic.

Scenarios

  • To store custom topic data for query purposes, create a time series data storage rule. To write additional custom topic data into time series storage, modify the existing rule in the console or invoke WriteDevicesHotStorageData.

  • For long-term storage of custom topic data, to reduce costs, or to process the data further using tools like Data Analysis or Data API, enable Data Backup. This automatically creates a corresponding Custom Storage Table in Offline Storage. The table name follows the format Time Series Storage Rule ${Rule ID}-Random ID. Re-enabling Data Backup after it has been disabled will continue writing to the previously created custom storage table.

Create Time Series Data Storage Rules

Note

A maximum of 1,000 time series data storage rules can be created per instance.

  1. Access the IoT Platform Console.

  2. Navigate to the Instance Overview page, locate the enterprise edition instance, and click to enter the Instance Details page.

  3. In the left-side navigation pane, select Data Service > Data Storage.

  4. Click the Time Series Storage tab, navigate to the Storage Rules tab, and then select Create Rule.

  5. Follow the configuration wizard to complete the setup.

Step 1: Configure Basic Information

  1. Input the rule name and description.

    Parameter

    Description

    Rule Name

    Specify a rule name between 1 to 30 characters, including letters, digits, underscores (_), and hyphens (-). Note that each Chinese or Japanese character counts as two characters.

    Rule Description

    Provide a brief description of the rule.

  2. Select Next. If you choose Cancel, the rule will still be created. You can later view and configure the data source topic and data processing script from the storage rule list. For details, refer to View and Update Time Series Data Storage Rules.

Step 2: Add Data Source Topic

Note

You can add up to 1,000 topics per rule.

  1. On the Add Data Source Topic page, click Add Topic.

  2. In the dialog box, select the product, device, and custom topic as prompted. Topics support the following wildcard characters:

    • All Devices (+): Matches all devices under the specified product.

    • user/#: Matches all custom topics of the specified device.

      image.png

  3. Click OK. The data source topic list will display the added topic information.

    Once a custom topic is successfully added, it appears in the data source topic list with its details.

    Important

    Once added, custom topics cannot be modified. To change, you must first Delete the topic and then add it again.

  4. (Optional) Repeat the above steps to add multiple data source topics.

  5. Select Next. If you choose Cancel, the added data source topic list can be viewed on the Rule Details page. For more information, see View and Update Time Series Data Storage Rules.

Step 3: Edit Data Processing Script

  1. On the Edit Data Processing Script page, enter the script in the Edit Script box to parse custom topic data for storage in time series storage.

    Important

    Ensure the data type for the same field key and value remains consistent under the same time series data storage rule. Changes in data type (e.g., from int32 to text) will cause new data to fail to write and prevent querying of historical storage data.

  2. Click Save to finalize the script editing.

  3. Select Debug to test and automatically save the script draft.

  4. In the right Debug panel, follow the prompts to select the product and device, enter the topic and payload data, and click Debug to validate the script.

    The Topic and Payload data must align with the script parsing logic.

    The Execution Result displays the variable values declared in the script and the executed data storage functions.

  5. Click Close on the Debug panel.

  6. (Optional) Click Publish to make the script live. You may also edit, re-debug, or publish the script later.

  7. Select Complete And Publish to finish the rule configuration and close the wizard.

  8. Return to the Time Series Storage > Rule Storage tab and click Start for the rule. Once started, the device's custom topic data will be stored according to the parsing script.

View and Update Time Series Data Storage Rules

  1. Under the Time Series Storage tab, locate the desired storage rule within the Storage Rules tab and click View in the Actions column.

  2. The Rule Details page presents information such as rule ID, creation time, data source topics, and data processing script details.

  3. To view and update the rule, follow the steps outlined below.

Edit Rule Basic Information

  1. Click Edit in the upper right corner of the page.

  2. In the Edit Rule dialog box, you can modify the Rule Name and Rule Description as needed.

Update Data Source Topic

On the Data Source Topic tab:

  • To add more data source topics, click Add Topic and refer to Step 2: Add Data Source Topic in the previous section.

  • To remove a topic, click Actions next to the relevant topic in the list and select Delete.

Update Data Processing Script

  1. Navigate to the Data Processing Script tab.

  2. To edit the script, click Edit Draft above the script input box.

  3. Make the necessary changes to the script in the input box.

  4. To finalize the update, click Save, then Debug, and finally Publish.

Optional Operations

Within the Time Series Storage > Rule Storage tab:

  • To stop a rule, click Actions and then Stop. Once stopped, the rule will no longer store custom topic data in time series storage.

  • To delete a rule, click Actions and then Delete. Note that the rule must be stopped before it can be deleted.

  • For Data Backup, toggle the switch to enable writing custom topic data from time series storage to a custom storage table, which can be utilized for Data Analysis, Data API, and other functionalities.

    To disable data backup, ensure the custom storage table that contains the custom topic data is not deleted before disabling the feature. Delete the custom storage table only after disabling data backup.