Run Logs
IoTDA can record the connections with devices and applications and report logs to Log Tank Service (LTS). LTS provides real-time query, massive log storage, log structuring, visualization, and analysis capabilities. It provides a free quota of 500 MB per month. When this quota is used up, you will be billed for any excess usage on a pay-per-use basis. For details, see What Is Log Tank Service?.
Currently, only service run logs of MQTT devices can be recorded. For details, see the following table.
Service Type |
Service Flow |
---|---|
Device status |
A device goes online. |
A device goes offline. |
|
Device message |
An application calls the device message API. |
The platform delivers a message to a device. |
|
The device reports the message to the platform. |
|
Device command |
An application calls the device command API. |
The platform delivers a command to a device. |
|
Device property |
An application calls the API for modifying device properties. |
A device reports properties. |
|
A gateway reports device properties in batches. |
|
The platform sets device properties. |
The following table describes the run log format. Each field is separated by a vertical bar (|).
Field |
Description |
---|---|
Time |
Log collection time. The time format is yyyy-MM-dd'T'HH:mm:ss,SSS'Z'. Example: 2020-06-16T09:24:45,708Z |
Device ID |
Device ID. |
Service type |
Options: device.status device.message device.command device.property |
Operation |
Operation name. Example: API URL or MQTT message topic. |
Request parameter |
Request parameter of an operation. Example: API request body. |
Result information |
Operation result. Example: API response body or error information. |
Execution status |
Operation status code. |
Procedure
- Access the IoTDA service page and click Access Console.
- In the navigation pane, choose
, and click Configure Run Log.Figure 1 Configuring the log function
- On the displayed dialog box, select the service type for data collection and click OK.
Figure 2 Configuring the log function
- Create a run log forwarding rule to forward the collected log data to other cloud services, so that you can view and process it. You are advised to forward log data to LTS. The following uses LTS as an example.
- In the navigation pane, choose Create Rule. , and click
- Configure parameters by referring to the following table, and click Create Rule.
Table 3 Creating a rule Parameter
Description
Rule Name
Specify the name of a rule to create.
Description
Describe the rule.
Data Source
Select Run log.
Trigger
After the data source is selected, the platform automatically matches the trigger event.
Resource Space
You can select a single resource space or all resource spaces.
- Click the Set Forwarding Target tab, and then click Add to set a forwarding target.
Table 4 Setting the forwarding target Parameter
Description
Forwarding Target
Select Log Tank Service (LTS).
Region
Currently, log data can be forwarded only to LTS in the same region.
Log Group/log Stream
Select a log group and log stream of LTS. If no log group or log stream is available, create them by referring to Managing Log Groups and Managing Log Streams.
Logs are retained in the log group for 7 days by default. Logs older than the retention period will be automatically deleted. For long-term storage, you can transfer logs to Object Storage Service (OBS) buckets. For details, see Transferring Logs to OBS.
LTS provides a free quota of 500 MB per month. By default, it continues to collect logs when the quota is used up. You will be billed for the excess usage on a pay-per-use basis. You can log in to the LTS console and choose Configuration Center to disable this function.
- Click No, and then click Enable Rule to forward run logs to LTS.
- Log in to the LTS console and choose Log Management.
- Select the log group and log stream created in 3 to view the logs reported by IoTDA. You can search for raw and target logs by referring to Log Search. For example, you can search for logs by device ID or service type.
Figure 3 Viewing logs
Figure 4 Viewing logs
- On the log stream details page, click Visualization. On the log structuring page displayed, click Delimiter. You are advised to use | for extraction.
Figure 5 Log visualization
- Select a sample log that contains time, device ID, service type, operation, request parameter, result information, and execution status. Select |, click Intelligent Extraction, change the names of the extracted fields (for example, change them to accessTime, deviceId, serviceType, operate, request, response, and status), and change the field type to string. Click Save to complete the log structuring configuration. For details, see Structuring Logs.
Figure 6 Structuring logs
Figure 7 Structuring logs
- After the raw logs are structured, the service will respond. On the Log Management page, select the log group and log stream created in 3, and click Visualization to view target logs. You can query logs using SQL statements. For example, to query logs by device ID and service type, run select * where deviceId = '5ebac4b54d9b0202c5d8ef0c_test_log' and serviceType = 'device.property'.
Figure 8 Log visualization
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot