EMQX data ingestion
After you send simulated temperature and humidity data to the EMQX Platform over the Message Queuing Telemetry Transport (MQTT) protocol, you can use the EMQX Platform data integration feature to forward the data to Tablestore.
Prerequisites
-
EMQX Platform
EMQX Platform is an MQTT message middleware product from EMQ for the Internet of Things (IoT) domain. As the world's first fully managed MQTT 5.0 message cloud service, EMQX Platform provides a one-stop MQTT messaging service in dedicated, isolated environments. EMQX Platform helps you quickly build industry applications for the IoT domain and easily implement data collection, transmission, computation, and persistence for your IoT data.
-
You have created a dedicated EMQX cluster on the EMQX Platform.
-
You have created a VPC peering connection with the Alibaba Cloud platform to establish network connectivity between VPCs.
NoteIf you want to connect to resources using a public IP address, you must enable NAT Gateway.
-
You have downloaded the MQTT X tool to simulate sending data later.
-
-
Tablestore
-
You have activated the Tablestore service, created a Tablestore instance, created a time series table named temp_hum, and created a timeline with the metric name cloud. For more information, see Use the time series model in the console.
-
You have attached a VPC that has an established peering connection with the EMQX Platform to the instance. For more information, see Attach a VPC.
-
You have created an AccessKey pair, which includes an AccessKey ID and an AccessKey secret, for your Alibaba Cloud account or for a Resource Access Management (RAM) user that has Tablestore access permissions.
-
Step 1: Configure the Tablestore resource in the EMQX console
-
Go to the Data Integration page.
-
Log on to the EMQX Platform console.
-
Click your project.
-
In the navigation pane on the left, click Data Integration.
-
-
Create a connector.
-
On the Data Integration page, in the Data Persistence section, click Alibaba Tablestore.
-
On the New Connector page, configure the resource parameters as described in the following table.
Parameter
Required
Example
Description
Connector Name
Yes
c-f0****
Automatically generated by the system. This parameter cannot be modified.
Remarks
No
Test Tablestore
Remarks for the connector.
Endpoint
Yes
https://myinstance.cn-hangzhou.vpc.tablestore.aliyuncs.com/
The endpoint of Tablestore. If you use a VPC peering connection, use the VPC endpoint of Tablestore. If you connect over the public network, use the public endpoint of Tablestore.
Instance Name
Yes
myinstance
The name of the Tablestore instance.
AccessKey ID
Yes
LTAI********************
The AccessKey ID of your Alibaba Cloud account or RAM user.
AccessKey Secret
Yes
********************************
The AccessKey secret of your Alibaba Cloud account or RAM user.
Storage Model Type
Yes
Time Series
The value is fixed to Time Series and cannot be modified.
Enable TLS
No
Disabled
TLS is disabled by default. To transfer data over the TLS protocol, turn on the Enable TLS switch and configure the TLS information.
Advanced Settings
No
-
In most cases, you can keep the default configurations. To change settings such as the connection pool size, startup timeout, or health check interval, click Advanced Settings and modify the configurations as needed.
-
Click Test Connection to verify that the connection is working.
NoteIf a connection test error occurs, verify that the database configuration is correct.
-
After the test succeeds, click New.
A dialog box appears, indicating that the connector has been created.
-
-
Create a rule.
After you create the resource, you can configure an associated rule to define how data is processed.
-
In the Connector created successfully dialog box, click New Rule.
NoteOn the Data Integration page, you can also click the
icon in the Actions column of the target connector to create a new rule. -
On the New Rule page, enter the SQL statement for the rule.
The following sample SQL statement reads the client ID and payload from the
temp_hum/emqxtopic, and then reads the temperature and humidity values from the payload.SELECT payload.temp as temp, payload.hum as hum, clientid FROM "temp_hum/emqx"You can enable the Enable Debug switch, modify the test data based on the fields in the SQL statement, and then click Test to view the results.
-
Click Next.
-
-
Create an output action.
-
Configure the action parameters as described in the following table.

Parameter
Required
Example
Description
Use Connector
Yes
c-****
Select the Tablestore sink connector that you created.
Action Type
Yes
Alibaba Tablestore
The value is fixed to Alibaba Tablestore and cannot be modified.
Action Name
Yes
a-******
The value is fixed to the name of the new action and cannot be modified.
Remarks
No
Output action test
Remarks for the action.
Data Source
No
device_001
The identifier of the data source that generates the timeline. This can be left empty.
Table Name
Yes
temp_hum
The name of the Tablestore time series table.
Metric Name
Yes
cloud
The metric name for the time series table. This is the name of the physical quantity or monitoring metric measured by the timeline data, such as temp or hum, to indicate that the timeline records temperature or humidity.
Tags
No
Key: region
Value: hangzhou
Data tags. All data is processed as strings.
Fields
Yes
Key: clientid
Value: ${clientid}
Key-value pairs for fields. The system automatically detects the data type of each field. Tablestore column values support multiple data types, including Boolean, integer, floating-point number, string, and binary. String data is processed as binary data by default to ensure optimal character set compatibility.
In the Fields section, click Add and configure the field column, message value, and whether the value is an integer or binary.
Timestamp
No
1663298365000000
The time corresponding to the row of time series data. The format is a timestamp in microseconds (us).
The default value is the timestamp in microseconds when the message arrives at EMQX.
ImportantBy default, MQTT messages in EMQX have a timestamp with millisecond precision, which cannot be used directly.
Metadata Update Mode
No
MUM_NORMAL
The update mode for time series metadata. Valid values are:
-
MUM_NORMAL (default): Normal mode.
-
MUM_IGNORE: Do not update metadata.
Advanced Settings
No
-
In most cases, you can keep the default configurations.
To change settings such as the cache pool size, request timeout, health check interval, or maximum cache queue length, click Advanced Settings and modify the configurations as needed.
-
-
Click Confirm.
A Rule created successfully dialog box appears.
-
-
Test the rule.
After creating the rule, test it to ensure that it works correctly.
-
In the Rule created successfully dialog box, click Go to Test Rule.
NoteYou can also go to the Data Integration page, click the target rule name, and then on the Settings tab, enable the Enable Debug switch to test the rule.
-
If debugging is not enabled, enable the Enable Debug switch.
-
On the Test Rule tab, click Start Test.
-
Click Input Simulated Data, and then configure the client ID, topic, and payload on the Simulated Data panel.

-
Click Submit Test.
The test results are displayed on the Test Rule tab. You can view the data stored in Tablestore in the Tablestore console.

-
Step 2: (Optional) Use the MQTT X tool to simulate reporting temperature and humidity data
Use the MQTT X tool to simulate sending temperature and humidity data to test the data storage.
-
Create credentials.
After you create the credentials, you can use them in the MQTT X tool to connect to the EMQX Platform.
-
Log on to the EMQX Platform console.
-
Click your project.
-
In the navigation pane on the left, choose .
-
On the Default Authentication tab, click Add.
-
In the Add Authentication dialog box, set the username and password, and then click Confirm.
-
-
Obtain the endpoint and port of the EMQX cluster.
Obtain the deployment endpoint to connect to the deployed EMQX cluster.
-
Log on to the EMQX Platform console.
-
Click your project.
-
On the Overview page, obtain and record the Connection Address and connection port information.
-
-
Use the MQTT X tool to simulate sending temperature and humidity data.
-
Download and install the MQTT X tool.
-
Open the MQTT X tool and click New Connection.
-
Configure the basic connection parameters as described in the following table. You can keep the default values for other parameters.

Parameter
Required
Example
Description
Name
Yes
emqxtest
A custom name for the connection from the MQTT X tool to EMQX Platform.
Host
Yes
p*******.***.*********.aliyun.emqxcloud.cn
The deployment endpoint of the EMQX cluster. Enter the Connection Address that you obtained from the EMQX Platform console.
Port
Yes
1883
The MQTT service port of the EMQX cluster. Enter the connection port that you obtained from the EMQX Platform console.
Username
Yes
test
The username and password used to connect to EMQX Cloud. Enter the username and password that you set when you created the credentials in the EMQX Platform console.
Password
Yes
********
-
Click Connect.
-
-
Send test data.
-
Click New Subscription.
-
In the New Subscription dialog box, configure the Topic and QoS, and then click Confirm.
This example uses the topic
temp_hum/emqx. -
Set the payload format to JSON, and configure the topic name and message body.
The following is a JSON example:
{ "temp": "35.6", "hum": "99" } -
Click the
icon to send the message.
-
Step 3: Verify the data in the Tablestore console
-
Go to the Time Series Tables tab.
-
Log on to the Tablestore console.
-
In the top navigation bar, select a resource group and a region.
-
On the Overview page, click the instance name.
-
On the Instance Details tab, click Time Series Tables.
-
-
On the Time Series Tables tab, click the name of the time series table and then click the Data Management tab. Alternatively, click Data Management in the Actions column.
-
On the Data Management tab, enter cloud for the metric name, select 1 hour for the time range, and click Query.

icon to send the message.