Is there a way to get number of messages per IoT device sending to IoT Hub

Mohammad Ajmal Yazdani 391 Reputation points
2022-07-27T16:15:02.403+00:00

Hello,

Below code gives me current messages count for IoT hub which is overall count of messages from all the devices.

var iotHubClient = await GetIotHubClient();  
                var mi = await iotHubClient.IotHubResource.GetQuotaMetricsAsync(Configuration["ResourceGroupName", "IotHubName");  
                foreach (var info in mi)  
                {  
                    if (info.Name != "TotalMessages") continue;  
                    if (info.CurrentValue != null)  
                    {  
                        var currentMessageCount = ((long)info.CurrentValue);  
                    }  
                }  

Is there a way to find out which device sending how much data, some kind of metrics by which I can identify the device which is sending more messages and I can take some action?

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

Accepted answer
  1. Sander van de Velde | MVP 33,636 Reputation points MVP
    2022-07-27T19:15:44.577+00:00

    Hello @Mohammad Ajmal Yazdani ,

    the IoT Hub offers metrics per IoT Hub only.

    It does not collect or shares data over individual devices.

    If you want to know how much your device is consuming, you need to collect/program your own metrics. This is a common non-functional requirement.

    This can be done by adding logic to Azure Stream Analytics jobs, Azure functions, or querying the cold path/ data lake (perhaps Azure Data Explorer?) if you have this in place.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.