Azure IoT Hub | IoT Solution Routing Metrics Logging

Set Up IoT Hub for Routing Metrics Logging | Azure IoT Developer Exam

Question

You are operating an IoT solution which collects sensor data from a wide range of field devices, including speed sensors, cameras etc.

You have configured several message routes depending on the telemetry data and on the geographical location of the devices.

In order to ensure smooth operation, you want to set up a solution to log all routing related metrics so that you can visualize and analyze them using Azure tools.

What settings should you make in the IoT Hub?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: B.

Option A is incorrect because IoT Hub / Metrics is for setting up charts and dashboards for visualizing selected metrics in order to get real-time insights on the IoT Hub.

It is not for setting-up log collection.

Use Diagnostic settings instead.

Option B is CORRECT because the best way to collect logs about any device-related events for visualization and evaluation purposes is forwarding them to an Azure Log Analytics workspace.

In order to connect your IoT Hub to a LA workspace, a diagnostic setting must be defined.

The log category (in this case: “Routes”) must also be selected.

Option C is incorrect because while the log data can be forwarded to Event Hubs, it is recommended for scenarios where the data is to be analyzed by external applications.

Option D is incorrect because IoT Hub / Logs is for querying and analyzing logs that have been collected before.

It is not for setting-up log collection.

Use Diagnostic settings instead.

References:

To set up a solution to log all routing related metrics in Azure IoT Hub, you should configure the diagnostic settings to send the logs to a Log Analytics workspace or an event hub.

The correct answers to the question are B. Diagnostic settings / Send to Log Analytics workspace and C. Diagnostic settings / Stream to an event hub.

Option A. Metrics / Routing: <metrics> is not a valid setting in Azure IoT Hub.

Option D. Logs / Send to Log Analytics Workspace is also a valid setting, but it is used to send logs to a Log Analytics workspace, not metrics related to message routing.

Here is a more detailed explanation of the two correct answers:

B. Diagnostic settings / Send to Log Analytics workspace You can use diagnostic settings to collect logs from Azure IoT Hub and send them to a Log Analytics workspace. To do this, you need to create a Log Analytics workspace and configure the diagnostic settings to send the logs to this workspace. You can then use Azure Monitor to analyze the logs and create visualizations to monitor the performance of your message routing.

To set up diagnostic settings in IoT Hub, follow these steps:

  1. In the Azure portal, navigate to your IoT Hub.
  2. Under Monitoring, select Diagnostic settings.
  3. Select Add diagnostic setting to create a new diagnostic setting.
  4. Give your diagnostic setting a name.
  5. Under the category Logs, select the types of logs you want to collect (e.g. Device telemetry logs, C2D commands logs).
  6. Under Destination details, select Send to Log Analytics workspace and select the Log Analytics workspace you want to send the logs to.
  7. Click Save to create the diagnostic setting.

C. Diagnostic settings / Stream to an event hub Another option to log routing related metrics is to stream the diagnostics data to an event hub. This option allows you to use the Azure Stream Analytics service to analyze and transform the data in real-time.

To set up diagnostic settings to stream data to an event hub in IoT Hub, follow these steps:

  1. In the Azure portal, navigate to your IoT Hub.
  2. Under Monitoring, select Diagnostic settings.
  3. Select Add diagnostic setting to create a new diagnostic setting.
  4. Give your diagnostic setting a name.
  5. Under the category Metrics, select the types of metrics you want to collect (e.g. Total messages sent, Total messages routed).
  6. Under Destination details, select Stream to an event hub and select the event hub you want to send the metrics to.
  7. Click Save to create the diagnostic setting.

In summary, by configuring diagnostic settings in Azure IoT Hub to either send logs to a Log Analytics workspace or stream data to an event hub, you can collect routing-related metrics and use Azure tools to visualize and analyze them.