To enable the edgehub_messages_sent_total metric in the Metrics Collector for detecting offline IoT Edge devices, you need to ensure that the Metrics Collector module is properly configured to collect and transport metrics from your IoT Edge devices to Azure Monitor. Here are the steps you should follow:
- Deploy the Metrics Collector Module: Make sure that the metrics-collector module is included in your IoT Edge deployment. This module is responsible for collecting metrics from other modules, including the
edgehubmodule. - Configure the Metrics Collector: In the configuration of the metrics-collector module, you need to set the appropriate environment variables. Ensure that the
ResourceIdis set to your IoT hub resource ID, and theUploadTargetis set toAzureMonitor. This configuration allows the metrics to be sent to Azure Monitor. - Check the Route Configuration: Ensure that the metrics are routed correctly. If you want to send metrics to Log Analytics, you may not need to set up a specific route to upstream, but ensure that the metrics collector is configured to send data to the correct Log Analytics workspace.
- Review Query in Log Analytics: Once the metrics are being collected, you can use Log Analytics to query for the
edgehub_messages_sent_totalmetric. You might need to adjust your query to ensure it captures the relevant data points for offline devices. The default query for detecting offline devices may need to be modified to include checks for the absence of messages sent. - Monitor the Metrics: After making these configurations, monitor the metrics in Azure Monitor to ensure that
edgehub_messages_sent_totalis being populated. It may take some time for the data to appear after the configurations are applied.
By ensuring that the metrics collector is properly set up and configured, you should be able to detect offline IoT Edge devices using the edgehub_messages_sent_total metric.
References: