Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Home
  • Knowledge base
  • Contact Us
  • Home
  • Tutorials & Guides
  • Azure
  • Azure IoT Hub & Device Provisioning Service

Monitoring IoT Hub events, messages & metrics

How to monitor events, messages and metrics in IoT Hub

Written by Mads Mikkelsen

Updated at May 3rd, 2024

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Installation & Technical information
    Introduction SIA Connect Standalone SIA Connect ANY-Ware Cellular & WiFi connectivity
  • Configuration in the Web UI
    Getting started with the UI Connectors Instances Items Mapping Data System Network Tools & Add-ons DigiCert IoT Trust Manager
  • Connectors
    Siemens S7 Azure IoT Ethernet/IP Mitsubishi MELSEC OPC-UA Server SQL MQTT Omron Host Link REST API Omron FINS Keyence Beckhoff TwinCAT BACnet Virtual OPC-UA Client MS SQL File M-Bus Modbus
  • Scripting & Variables
    Data formatting
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    InfluxDB AWS IoT Core - Amazon Web Services Microsoft Power BI KaaIoT Siemens S7 AVEVA Insight SIA Connect Demo Rack Grafana Azure
  • General
+ More

Table of Contents

How to use Azure IoT Explorer to monitor messages Events & Message in Azure CLI Info Metrics Info Video of monitoring metrics & events

Articles in this section:

  • Creating a IoT Hub and device in Azure
  • Getting device Connection String from Azure IoT
  • Connecting PLCs to Azure IoT Hub
  • Monitoring IoT Hub events, messages & metrics
  • How to get started with Azure Device Provisioning Service in IIoT
  • Understanding telemetry message and properties in Azure IoT

Table of Contents

How to use Azure IoT Explorer to monitor messagesEvents & Message in Azure CLIVideo of monitoring metrics & events


Messages that are being sent to IoT Devices in Azure IoT Hub can be monitored. Monitoring messages arriving in IoT Hub is very useful when debugging and troubleshooting. 

Messages can be monitored as general metrics but you can also monitor them on message level by using Azure CLI tool or by using Azure's own desktop client Azure IoT Explorer


How to use Azure IoT Explorer to monitor messages

Azure IoT Explorer is a handy tool delivered by Microsoft to help troubleshooting and monitoring messages being sent from edge devices and to Azure IoT Hub.

Delete

Telemetry messages will NOT appear in Azure IoT Explorer if you have other ressources consuming the messages such as Azure Functions

To get started with Azure IoT Explorer follow the below steps:

  1. Download and install Azure IoT explorer from Azures Github repository. Click here for full guide
  2. After installation an IoT Hub needs added. Go to IoT Hubs and click Add connection
  3. Enter the connection string of the IoT Hub owner. Find this in the Azure portal under Security settings, Shared access policies and then click on iothubowner policy. Copy paste one of the connection strings.
  4. In Azure IoT explorer you should see the added IoT Hub and all the devices
  5. Click on the desired device which you want to monitor the telemetry from or sending Cloud-to-devices to
  6. In the menu go to Telemetry and press start. Incoming messages will be present.



Events & Message in Azure CLI

To see the message details for all messages coming in you will have to use the Azure CLI.

For further information of Azure CLI on your desktop and the Azure Cloud Shell check these articles:

  • Install the Azure CLI | Microsoft Docs
  • Azure Cloud Shell overview | Microsoft Docs 
  • Monitoring Azure IoT Hub | Microsoft Docs


Info

Using the Azure Cloud Shell you might need to add storage to your account and install azure-iot extensions


To monitor the events and messages do the following if you are using the Azure Cloud Shell:

Click the terminal icon in the portals upper right corner next to your username.

When the Cloud Shell is ready use one of the following command to monitor all messages arriving into the IoT Hub

az iot hub monitor-events --hub-name HubName
az iot hub monitor-events --login "ConnectionString"


Or to monitor for a specific Device, which is very useful if you have many devices and are getting a lot of messages

az iot hub monitor-events --hub-name HubName --device-id DeviceID


To view more details of each message such as user defined and system properties use the following command

az iot hub monitor-events --hub-name HubName --device-id DeviceID --properties app sys
az iot hub monitor-events --login "ConnectionString" --properties app sys


To get a full list of parameters and help use

az iot hub monitor-events -h


HubName and DeviceID can be located in IoT Hub ➡ IoT Devices

  • HubName is your IoT Hub name
  • DeviceID is the ID of the Device
  • ConnectionString is the connection string of your IoT Hub or device. Learn how to find ConnectionString here‍


In Azure CLI the format of message event in to the device is as follows

{
    "event": {
        "origin": "DeviceID",
        "module": "",
        "interface": "",
        "component": "",
        "payload": "MessagePayload"
    }
}


and when monitoring with all the properties it looks as

{
    "event": {
        "origin": "DeviceID",
        "module": "",
        "interface": "",
        "component": "",
        "properties": {
            "application": {
                "UserProperty1": "UserValue1",
                "UserProperty2": "UserValue2",
                ....
            }
        },
        "payload": "MessagePayload"
    }
}

where 

  • UserProperty & UserValue is the custom user properties and values added from SIA in the properties field
  • MessagePayload is the payload being sent from SIA and being parsed to the IoT Hub



Metrics

In Azure IoT Hub you have metrics available for the given hub. This metrics can shows you information such as telemetry messages being sent.
Viewing the amount of telemetry messages sent to the IoT Hub is a really basic way of validating it works and cannot give you further information than data is coming in. Please keep in mind if you have multiple devices which are receiving data on the Hub this metrics might not be suitable to use as their telemetry messages will also appear.

  • In Azure Portal go to IoT Hub and select the Hub where your IoT device belongs to
  • In the left menu go to Monitoring ➡ Metrics
  • Add new metric
    • Metric: Telemtry messages sent
    • Aggregation: Sum (you can use any of those available)
  • Select a suitable time range in in the top right of the metric
  • Analyze the metric and validate the data graph


Info

It can take a few minutes before the metrics start to update





Video of monitoring metrics & events

The following video shows you how to monitor metrics and events from Azure IoT Hub.


event tracking iot hub

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Getting device Connection String from Azure IoT
  • Connecting PLCs to Azure IoT Hub
  • Creating a IoT Hub and device in Azure

0
0
Expand