How to check total number of connected devices in IoT hub

jb_devel 120 Reputation points
2025-02-04T05:08:25.6333333+00:00

Hello,

First Im not a cloud engineer and we currently dont have one as of the moment so this is a problem for us.

I would like to ask how to check the number of active devices currently connected to our IoT hub. Our devices reboots randomly everyday and im sure its sending some message to azure when it reboots.

Thank you!

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,244 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Manas Mohanty 745 Reputation points Microsoft Vendor
    2025-02-04T05:57:51.1033333+00:00

    Hi jb_devel!

    Welcome to Azure IOT Q and A forum. Thank you for posting your query here.

    To see connected Devices on IOT Hub

    1. You can go to "monitoring" section from Azure IOT Hub resource in portal.azure.com
    2. View metrics - then select "Connected Devices" and select a time span as scope

    Reference on Metrics

    You can set up a trigger alert based on device count metric

    Reference on triggering alert

    You can opt for "event grid" if you want to tune in device reboots, connects etc. as it provides low latency compared to Azure Monitor.

    Reference on per event grid

    Please don't forget to upvote this answer if it is useful to you.

    Thank you.


  2. Sander van de Velde | MVP 35,091 Reputation points MVP
    2025-02-04T10:32:14.6666667+00:00

    Hello @jb_devel ,

    welcome to this moderated Azure community forum.

    the Azure IoT Hub shows metrics about the number of devices being connected.

    This metric is not real-time, it is updated once every few minutes. And it does not show a reliable history of connections/disconnections.

    On the other hand, the IoT Hub exposes non-functional events about devices:

    User's image

    There are events for creating and deleting devices, for changes to the device twin, and connectivity.

    Check this blog post about the details on how to configure this via the routes.

    It references the deprecated TimeSeries Insights service but you can also route the messages to the free Azure Data Explorer (or a paid one with an SLA) via a stream analytics job and an eventhub.

    This stream analytics job is needed because the details of the connection state and the device name are in the application properties. The Azure Data Explorer is not capable of exposing application properties in the database.

    Therefor, the application properties should be moved to the actual message body.

    As @Manas Mohanty mentioned, the IoT Hub also exposes EventGrid events for this.

    If this is too complex at this moment, you can start with routing the events to a blob file in a storage account.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.