By default, you can view the logs generated in the last seven days in the Device Log module of the IoT Platform console. You can also export logs from the module to a Logstore of Log Service for persistent storage. After you enable the IoT Platform log dump feature, you can query and analyze logs, view and subscribe to log reports, and configure alerts in the IoT Platform console.
Prerequisites
Log Service is activated. For more information, see Resource management overview.
Usage notes
The log dump feature is available only for Alibaba Cloud accounts. RAM users are unable to use this feature.
When the log dump feature is enabled, the logs are shipped to and stored in Alibaba Cloud Log Service. You are charged for storing logs in the Logstore based on the pricing of Log Service. For more information, see Overview.
Enable the IoT Platform log dump feature
If you want to store logs from more than one product for an extended period, you must enable the log dump feature for each product.
Use the log query and analysis feature
After you enable the IoT Platform log dump feature, you can perform the following operations on the IoT Platform Log Dump tab:
- Raw Logs:
Operation Description Query and analyze logs The Raw Logs tab allows you to use SQL statements to query logs within a specified period of time and perform statistical analysis. For more information about the SQL syntax, see Search syntax and Log analysis overview. View charts The Graph tab allows you to view the generated charts. Aggregate logs The LogReduce tab allows you to aggregate similar logs and obtain a more comprehensive view of your business. Perform quick analysis After you query logs, you can analyze the query result and view the distribution of a field in the result. Configure an alert rule If an alert condition is met, IoT Platform sends an alert by text message, phone call, email, or DingTalk notification. - Log Report:
Operation Description View reports You can view log reports in a specified time range. Log reports reflect the statuses and exceptions of devices. For more information about log reports, see the following table that describes various log reports. By default, a log report shows the data of the last hour that starts and ends on the hour. The data is collected at an interval of one minute in line charts.
- To specify a time range, you can click Time Range in the upper-right corner of the Log Report tab or choose > Select Time Range in the upper-right corner of a chart.
- To change the resolution of your line chart, go to the Raw Logs tab and create an SQL statement that queries data collected at a specified interval.
For more information about the SQL syntax, see Date and time functions.
For example, you can use the following statement to set the time interval to one hour:
bizCode:device | SELECT date_format(date_trunc('hour',__time__), '%m-%d %H:%i') AS Time, count(1) AS count , operation GROUP BY Time, operation ORDER BY Time limit 1440
.
Subscribe to reports IoT Platform regularly converts reports into images and sends these images to the specified contacts by using emails or DingTalk chatbots. Table 1. Log reports Report Chart type Description Number of Times Device Online & Offline Line chart The line chart shows the number of times that devices are connected to IoT Platform and the number of times that devices are disconnected from IoT Platform in a specified period of time. Device Uplink & Downlink Messages Line chart The line chart shows the number of upstream messages and the number of downstream messages in a specified period of time. Top 20 Devices by Uplink&Downlink Message List The list shows the top 20 devices that send or receive the most upstream or downstream messages, and the number of messages of each device. Error Distribution for Data Parsing Script Pie chart The pie chart shows the distribution of data parsing errors in a specified period of time. You can query logs by error code and view the details of data parsing errors in logs. This helps improve a data parsing script effectively.
Top 10 Devices by Data Parsing Script Error List The list shows the top 10 devices on which the most data parsing errors occur, and the number of errors that occur on each device in a specified period of time. You can query logs by device name and view the details of data parsing errors in logs. This helps improve a data parsing script effectively.
Error Distribution for TSL Validation Pie chart The pie chart shows the distribution of Thing Specification Language (TSL) validation errors in a specified period of time. You can query logs by error code, view the details of TSL validation errors in logs, and troubleshoot errors.
Top 10 Devices by TSL Validation Error List The list shows the top 10 devices on which the most TSL validation errors occur, and the number of errors that occur on each device in a specified period of time. You can query logs by device name, view the details of TSL validation errors in logs, and troubleshoot errors.
Server-side Subscription Messages Forwarded Line chart The line chart shows the total number of messages that are forwarded by an Advanced Message Queuing Protocol (AMQP) or Message Service (MNS) server-side subscription in a specified period of time. Last 20 Device Anomaly Messages Pie chart The pie chart shows the last 20 device error messages. You can query logs by device name and error code, view the details of device error messages in logs, and troubleshoot errors.
Cloud Service Messages Forwarded Line chart The line chart shows the total number of messages that are forwarded by the data forwarding feature in a specified period of time. Last 20 Data Forwarding Errors List The list shows the last 20 data forwarding errors of the rules engine in a specified period of time. You can query logs by device name and error code, view the details of data forwarding errors for the rules engine in logs, and troubleshoot errors.
Error Distribution for Cloud API Calls Pie chart The pie chart shows the distribution of errors in API calls in a specified period of time. You can query logs by API operation name and troubleshoot errors based on log details and error codes.
Disable the IoT Platform log dump feature
You can disable the IoT Platform log dump feature for a specific product at any time as needed to save storage space.