Azure IoT Hub: Number of messages used by devices

Brian Toan 45 Reputation points
2023-12-11T09:41:29.7033333+00:00

I have IoT devices from a company named Senquip. I attach these devices to my equipment, and it will send data about my equipment to the Senquip web portal, in addition to whatever destination I want it to send.

I'm using Azure IoT Hub to stream events from my Senquip devices through MQTT. I added 4 of these devices into Azure IoT Hub, and then route the messages to Azure Blob Storage to store data for analytics. It has been a success so far.

Recently I found that one of the devices (let's call this device A) are not sending all events to Azure IoT Hub. When checking on the web portal, it shows about 10 events within a certain timeframe (let's call this timeframe T). When checking the same timeframe T on Azure Blob Storage, I only find 1 event.

I suspect maybe IoT Hub did receive all 10 events, but maybe something went wrong with the message routing when it routes the messages to Azure Blob Storage. I want to check the number of messages received by device A in timeframe T, but don't know how to do this. I was thinking of looking at the Number of messages used metrics in IoT Hub > Overview, but this metric can not be filtered by device id.

How can I filter this Number of messages used metric by IoT Hub device id? If that's not possible, is there any way to check the number of messages received by that IoT Hub device in a certain timeframe? Any other way to debug if a device receives a message, but that message is not routed to Azure Blob Storage?

Thank you so much for your help!

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

Accepted answer
  1. Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
    2023-12-11T12:09:01.73+00:00

    Hello @Brian Toan,

    welcome to this moderated Azure community forum.

    The IoT Hub does not expose the number of messages per device.

    There are some metrics in the backend available as seen in the 'Diagnose and solve problems page, Issues with device-to-cloud messages' but these are not queryable:

    User's image

    If you want to count individual messages per device, you need to write custom logic, listening to routed messages using the routing mechanism.

    Notice the IoT Hub is not counting individual messages but 'chunks'. Each message is divided into 4Kb blocks (S1 and higher).

    So, a message of 6Kb is counted as two chunks thus 2 'IoT Hub messages'.


    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.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 17,766 Reputation points Moderator
    2023-12-11T21:49:10.19+00:00

    Thank you @Sander van de Velde | MVP for your inputs on this.

    Hi @Brian Toan , as Sander pointed, the current implementation of IoT Hub does not provide an out of the box mechanism to track the telemetry send per device. You would need to build a custom logic/implementation to achieve this. Please refer to a similar question addressed in the past where a solution has been proposed leveraging device twin property and the service SDK to monitor per device telemetry.

    Kindly be cautious while updating the device twin property frequently as there are throttling limits applied on the twin updates. Please refer the below image for reference.

    User's image

    To overcome this, you may have a counter locally in your SDK and intermittently hit the device twin update end point to sync the messages sent.

    I highly appreciate it if you could propose this idea on the Azure IoT Hub ideas forum so that this feature can be upvoted by other community members looking into a similar ask. Kindly share the URL of the feature request link once it is posted so that community can upvote it.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments

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.