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 IoT Hub

Monitoring IoT Hub events, messages & metrics

How to monitor events, messages and metrics in IoT Hub

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.

  • Getting started
    Introduction to SIA Technical info Portal - Web App (UI) SIA Connect as Software
  • Using SIA
    Connectors Instances Items Mapping Scripting & Variables Data
  • Connectors
    Siemens S7 Azure 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
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    Azure IoT Hub Siemens S7 AWS IoT Core - Amazon Web Services Microsoft Power BI SIA Connect Demo Rack AVEVA Insight Azure IoT Central
+ More

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

Table of Contents

Events & Message in Azure CLIMetricsVideo 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. 


Events & Message in Azure CLI

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

Using Azure CLI gives a more detailed insight and details of messages and is recommended to use for monitoring


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.


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