Azure IoT Monitoring
Monitoring Azure IoT Solutions
Effective monitoring is crucial for understanding the health, performance, and security of your Azure IoT solutions. Azure provides a comprehensive suite of tools and services to help you collect, analyze, and act on telemetry and diagnostic data from your IoT devices and services.
This documentation section covers the key aspects of monitoring your Azure IoT deployments, including:
- Diagnostic Logs for Azure IoT Hub and other services
- Performance Metrics and their interpretation
- Setting up alerts for critical events and thresholds
- Common troubleshooting scenarios and patterns
💡 Best Practice: Implement a robust monitoring strategy early in your IoT project lifecycle to ensure scalability and reliability.
Diagnostic Logs
Diagnostic logs provide detailed operational information about your Azure IoT resources. These logs capture events related to device connectivity, message telemetry, direct method calls, device twin updates, and more. They are essential for auditing, security analysis, and troubleshooting.
Azure IoT Hub emits several categories of diagnostic logs, including:
DeviceTelemetry
: Logs related to messages sent from devices to IoT Hub.OperationsMonitoringEvents
: Logs for operations performed on IoT Hub (e.g., device registration, twin updates).DeviceLifecycleEvents
: Logs for device connection/disconnection and related events.FileNotifications
: Logs for file upload notifications.
You can configure diagnostic settings to send these logs to various destinations:
- Log Analytics Workspace: For powerful querying and analysis using Kusto Query Language (KQL).
- Storage Account: For long-term archival.
- Event Hubs: For integration with other monitoring or SIEM solutions.
Enabling Diagnostic Logs for IoT Hub
To enable diagnostic logs for your IoT Hub:
- Navigate to your IoT Hub instance in the Azure portal.
- Under the Monitoring section, select Diagnostic settings.
- Click Add diagnostic setting.
- Select the log categories you want to capture.
- Choose one or more destination types (Log Analytics, Storage Account, Event Hubs) and configure them.
- Click Save.
Example: Querying device connection events in Log Analytics
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DEVICECONTINUITY" and ResourceType == "IOTHUBS"
| where Category == "DeviceLifecycleEvents"
| project TimeGenerated, OperationName, Computer, DeviceId, Status, Message
| order by TimeGenerated desc
Metrics
Metrics provide aggregated, numerical data about the performance and health of your Azure IoT resources over time. They are useful for understanding trends, capacity planning, and identifying potential issues before they become critical.
Key metrics for Azure IoT Hub include:
- Messages sent to IoT Hub: Number of messages received from devices.
- Messages received by IoT Hub: Number of messages sent from IoT Hub to devices.
- Device-to-cloud message count: Total count of D2C messages processed.
- Cloud-to-device message count: Total count of C2D messages processed.
- Device connect count: Number of currently connected devices.
- Active device count: Number of devices that have sent telemetry in the last minute.
- Command invocation count: Number of commands sent to devices.
These metrics can be viewed in the Azure portal or queried programmatically using the Azure Monitor API. They can also be used as the basis for creating alerts.
Alerts
Alerts notify you when specific conditions are met in your Azure resources. For IoT solutions, alerts can be configured for:
- High message latency
- Unusual spikes in device disconnections
- Approaching IoT Hub throttling limits
- Low battery levels reported by devices (if data is ingested and processed)
- Security-related events
Alerts can trigger various actions, such as sending an email, SMS, triggering a webhook, or running an Azure Function. This enables proactive responses to operational issues.
Creating an Alert Rule
- Navigate to Monitor in the Azure portal.
- Select Alerts, then click Create alert rule.
- Define the Scope (your IoT Hub or other relevant resource).
- Set the Condition based on a specific metric, log event, or activity log.
- Configure the Action group to define what happens when the alert is triggered.
- Provide a name and description for the alert rule.
✅ Tip: Use Log Alert rules to trigger alerts based on complex queries against your diagnostic logs, providing more granular control.
Troubleshooting Common Issues
When monitoring reveals issues, systematic troubleshooting is key. Common areas include:
- Device Connectivity: Check device logs, network configurations, and IoT Hub connection metrics. Ensure devices are authenticating correctly.
- Message Delivery: Verify message formats, routing rules, and message queue sizes. Look for errors in device-to-cloud (D2C) and cloud-to-device (C2D) paths.
- Throttling: Monitor IoT Hub metrics for throttle limits. If limits are being reached, consider scaling up your IoT Hub tier or optimizing message patterns.
- Device Twin Synchronization: Ensure desired properties are being reported and that there are no conflicting updates.
Leveraging the combination of diagnostic logs, metrics, and alerts provides a powerful framework for maintaining the health and performance of your Azure IoT solutions.