|
| 1 | +--- |
| 2 | +title: Diagnose and troubleshoot disconnects with Azure IoT Hub DPS |
| 3 | +description: Learn to diagnose and troubleshoot common errors with device connectivity for Azure IoT Hub DPS |
| 4 | +author: xujing-ms |
| 5 | +manager: nberdy |
| 6 | +ms.service: iot-dps |
| 7 | +services: iot-dps |
| 8 | +ms.topic: conceptual |
| 9 | +ms.date: 09/09/2019 |
| 10 | +ms.author: xujing |
| 11 | +# As an operator for Azure IoT Hub DPS, I need to know how to find out when devices are disconnecting unexpectedly and troubleshoot resolve those issues right away |
| 12 | +--- |
| 13 | +# Troubleshooting with Azure IoT Hub Device Provisioning Service |
| 14 | + |
| 15 | +Connectivity issues for IoT devices can be difficult to troubleshoot because there are many possible points of failures such as attestation failures, registration failures etc. This article provides guidance on how to detect and troubleshoot device connectivity issues via [Azure Monitor](https://docs.microsoft.com/azure/azure-monitor/overview). |
| 16 | + |
| 17 | +## Using Azure Monitor to view metrics and set up alerts |
| 18 | + |
| 19 | +The following procedure describes how to view and set up alert on IoT Hub Device Provisioning Service metric. |
| 20 | + |
| 21 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
| 22 | + |
| 23 | +2. Browse to your IoT Hub Device Provisioning Service. |
| 24 | + |
| 25 | +3. Select **Metrics**. |
| 26 | + |
| 27 | +4. Select the desired metric. |
| 28 | + <br />Currently there are three metrics for DPS: |
| 29 | + |
| 30 | + | Metric Name | Description | |
| 31 | + |-------|------------| |
| 32 | + | Attestation attempts | Number of devices that attempted to authenticate with Device Provisioning Service| |
| 33 | + | Registration attempts | Number of devices that attempted to register to IoT Hub after successful authentication| |
| 34 | + | Device assigned | Number of devices that successfully assigned to IoT Hub| |
| 35 | + |
| 36 | +5. Select desired aggregation method to create a visual view of the metric. |
| 37 | + |
| 38 | +6. To set up an alert of a metric, select **New alert rules** from the top right of the metric blade, similarly you can go to **Alert** blade and select **New alert rules**. |
| 39 | + |
| 40 | +7. Select **Add condition**, then select the desired metric and threshold by following prompts. |
| 41 | + |
| 42 | +To learn more, see [What are classic alerts in Microsoft Azure?](../azure-monitor/platform/alerts-overview.md) |
| 43 | + |
| 44 | +## Using Log Analytic to view and resolve errors |
| 45 | + |
| 46 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
| 47 | + |
| 48 | +2. Browse to your IoT hub. |
| 49 | + |
| 50 | +3. Select **Diagnostics settings**. |
| 51 | + |
| 52 | +4. Select **Turn on diagnostics**. |
| 53 | + |
| 54 | +5. Enable the desired logs to be collected. |
| 55 | + |
| 56 | + | Log Name | Description | |
| 57 | + |-------|------------| |
| 58 | + | DeviceOperations | Logs related to device connection events | |
| 59 | + | ServiceOperations | Event logs related to using service SDK (e.g. Creating or updating enrollment groups)| |
| 60 | + |
| 61 | +6. Turn on **Send to Log Analytics** ([see pricing](https://azure.microsoft.com/pricing/details/log-analytics/)). |
| 62 | + |
| 63 | +7. Go to **Logs** tab in the Azure portal under Device Provisioning Service resource. |
| 64 | + |
| 65 | +8. Click **Run** to view recent events. |
| 66 | + |
| 67 | +9. If there are results, look for `OperationName`, `ResultType`, `ResultSignature`, and `ResultDescription` (error message) to get more detail on the error. |
| 68 | + |
| 69 | + |
| 70 | +## Common error codes |
| 71 | +Use this table to understand and resolve common errors. |
| 72 | + |
| 73 | +| Error Code| Description | HTTP Status Code | |
| 74 | +|-------|------------|------------| |
| 75 | +| 400 | The body of the request is not valid; for example, it cannot be parsed, or the object cannot be validated.| 400 Bad format | |
| 76 | +| 401 | The authorization token cannot be validated; for example, it is expired or does not apply to the request’s URI. This error code is also returned to devices as part of the TPM attestation flow. | 401 Unauthorized| |
| 77 | +| 404 | The Device Provisioning Service instance, or a resource (e.g. an enrollment) does not exist. |404 Not Found | |
| 78 | +| 412 | The ETag in the request does not match the ETag of the existing resource, as per RFC7232. | 412 Precondition failed | |
| 79 | +| 429 | Operations are being throttled by the service. For specific service limits, see [IoT Hub Device Provisioning Service limits](https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-device-provisioning-service-limits). | 429 Too many requests | |
| 80 | +| 500 | An internal error occurred. | 500 Internal Server Error| |
0 commit comments