1

I recently started a project with Azure IoT Edge with the IoT Hub Free Tier so I'm a total beginner. I set up a device sensor, a module and I am sucessfully sending data to my module and IoT Hub. I can monitor the messages sent from the sensor with Azure IoT Hub expension from Visual Studio Code.

I can see the messages I'm sending but I am having an issue with the number of messages being sent. I use Azure portal metrics to monitor the number of messages sent and very often Azure would show me different numbers as I refresh. For example "1000" messages and after a refresh "800" messages etc...

Another issue I'm having is also that when using the Metrics functionality, it shows me that some messages are being sent during a time where my sensors weren't sending any messages.

Is there a way to get a detailled report with a history on the messages that the Hub receives?

Any help or advice would be highly appreciated! Thank you

milo1000
  • 13
  • 3

1 Answers1

1

As far as I know there is no "nice and simple" report which will show you what you need. However, if you want to get historical events which IoT hub processed it can be done. Note, though, that history is limited and can be no longer than 7 days. Current retention period can be seen on the azure portal in "Built-in endpoints" section - there is a "Retain for" setting with the value from 1 day (default) to 7 days.

If events are within this range, you can use Powershell command "az iot hub monitor-events" with the --enqueued-time parameter to "look back" in history. The time is specified in milliseconds since unix epoch. Example command:

az iot hub monitor-events --hub-name 'your_iot_hub_name' --device-id  'your_registered_device_id'  --properties all --enqueued-time 1593734400000
Artur
  • 146
  • 2
  • Another thing - to use this command you will need to install Azure CLI first and then install IoT hub extension using: az extension add --name azure-cli-iot-ext – Artur Jul 09 '20 at 09:41
  • Hey, thank you very much for your answer. I think I cannot set the retain for to 7 days with the free tier. It tells me the maximum is one day. Still this helps me even for only one day. Thank you very much for your help! Do you perhaps have an idea about what could be the reason why I keep on seeing a high number of messages even though I didn't send any? – milo1000 Jul 10 '20 at 11:07
  • @milo1000 I have never seen such behavior before. Are you using "Telemetry messages sent" metric or different one? One explanation can be is that there is a delay between your device sending the message and IoT hub receiving it. Does your message include the timestamp of when the message was sent? You can compare it with IoT hub standard message property "EnqueuedTime" - it shows when IoT hub got the message for processing. You should be able to access this property by using the command from my original reply. – Artur Jul 10 '20 at 11:52
  • @milo1000 Have you also checked "Throttled requests" metric? You are using free tier, so it can happen that you are exceeding the limit and the messages are throttled until the limit is reset (usually on 12 AM every night) – Artur Jul 10 '20 at 11:54
  • Hey, thannk you again for your answer. Concerning the throttled requests metric, I only found "Number of throtteling errors" and it's always 0. I actually always use the "IoT Hub Usage" Graph that I find on the IoT-Hub overview page. That one shows me more messages than I am sending. Regarding the Telemetry messages sent, they do show me the exact number and messages – milo1000 Jul 15 '20 at 11:17
  • yes, you need to use "Telemetry messages sent", as you can see the numbers match. "IoT hub usage" is a bit tricky, because it does not exactly count sent messages, but it counts how many messages from IoT hub quota were used. I can't find the exact size now, but when the message exceeds certain size, it will be counted more than once in "IoT hub usage", but "Telemetry messages sent" will still show one message. – Artur Jul 15 '20 at 12:55
  • Oh okay! That explains it then, I was really confused about the numbers showing there. Thank you very much for your help again! – milo1000 Jul 17 '20 at 10:47