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 local log dump feature, you can query and analyze logs and configure alerts in the IoT Platform console.

Prerequisites

  • An SDK for Android or SDK for C is used to develop a device. Logs are submitted by the device. For more information about how to reset a password, see Device log reporting.
  • Device local log reporting is turned on. To turn on the switch, you must log on to the IoT Platform and perform the following steps: 1. Choose Devices > Devices. 2. Find the required device in the device list and click View. 3. On the Device Details page, turn on Device local log reporting.
  • 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 local 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.

  1. Log on to the IoT Platform console.
  2. On the Overview page, find the instance and click the instance name to go to the Instance Details page.
    Notice Enterprise Edition instances are available only in the China (shanghai) and Japan (Tokyo) region. If your IoT Platform is not activated in the China (shanghai) or Japan (Tokyo) region, skip this step.
    Overview
  3. In the left-side navigation pane, choose Maintenance > Device Log.
  4. Select a product and click the Local Log Dump tab.
  5. Click Enable.
  6. Follow the on-screen instructions to enable the local log dump feature.
    Note If Log Service is not activated, you can click Enable to go to the Log Service activation page.
    1. In the dialog box that appears, click Create next to the Role and Log Storage Location sections.
      Note If Created is displayed next to the Role and Log Storage Location sections, skip this step.
    2. Click OK.
    After you enable the local log dump feature for the product, IoT Platform automatically creates a log storage location and a service-linked role that is used to export logs.
    • Log storage location:
      • Project: iot-log-${uid}-${regionId}. Replace the ${uid} variable with your Alibaba Cloud account ID and the ${regionId} variable with the ID of the region where IoT Platform resides.
      • Logstore: iot-logs-device-local.

      All devices that belong to your products connected to IoT Platform share the same log storage location. You can use the ProductKey parameter to differentiate between logs of different products. For more information, see Local device logs.

    • Service-linked role: You can use this role to obtain permissions to export logs. For more information, see AliyunServiceRoleForIoTLogExport service linked role.
  7. Specify the retention period of logs.
    Logs exported from IoT Platform are deleted when their retention period ends. You can set the retention period to 1 to 3,000 days. The default log retention period is 7 days. You can also turn on the Permanent Storage switch to retain logs permanently.

    On the Local Log Dump tab, click Set log save time. In the message that appears, click OK. On the Logstore Attributes page, click Modify, set the Data Retention Period parameter, and then click Save.

Use the log query and analysis feature

After you enable the local log dump feature, you can perform the following operations on the Local Log Dump tab.

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.

Disable the local log dump feature

You can disable the local log dump feature for a specific product at any time as needed to save the storage space.

  1. Log on to the IoT Platform console . On the Overview page, find the instance that you want to manage and click the instance.
  2. In the left-side navigation pane, choose Maintenance > Device Log.
  3. Select a product and click the Local Log Dump tab.
  4. Click Stop Dump. In the message that appears, click OK.
    After the local log dump feature is disabled, the newly generated local device logs are no longer exported to your Logstore. Logs that have already been exported to Log Service are not immediately deleted. They are deleted when the specified log retention period ends.