ms-iot / azure-client-tools

Azure Client Tools
Other
43 stars 37 forks source link

Overview of number of messages required #31

Closed thj-dk closed 5 years ago

thj-dk commented 5 years ago

We're currently evaluating Azure IoT Hub and Azure Client Tools for a new IoT related product. Since the number of messages affects the Azure price, I'm trying to estimate the number of messages that Azure Client Tools requires. Both when keeping the connection to the hub alive, reporting status and when doing the different operations.

Do you have any such numbers, or is there some way to log the messages sent to/from the hub so we can see for ourselves? Either in the IoT Hub, or on the device.

Is there any way to control how often some messages is sent to the hub?

gmileka commented 5 years ago

Hi thj-dk,

You can monitor the number of message on the IoT Hub page on portal.azure.com. For example, when I got to my IoT Hub page, and select 'Overview', I can see three panes:

  1. IoT Hub Usage (Message x/400000 Daily).
  2. Device twin operations.
  3. Device to cloud messages (events).

The Device Agent itself sends a message or two on start-up to report the available plug-ins. Then, each plug-in that's installed has its own number:

It's expected that the number of messages exchanged to be pretty low since the device configuration is not meant to change very often by the operator - and the Device Agent and its current plug-ins are passive for the most part as described above.

So, it is almost dependent on how many times a certain area is configured, and how many areas are configured. Of course, if there are custom plug-ins, then it depends on what those plug-ins do/report and how.

The part I am not familiar with is whether keeping the connection alive results in any message count. This can be determined by looking the Azure portal - but I doubt they count.

thj-dk commented 5 years ago

Thanks for the sum up @gmileka. Much appreciated.

These messages, are there any way to log these in the IoT Hub? When activating logging in the IoT Hub, I'm seeing entries with the categories Connections, D2CTwinOperation and C2DTwinOperation. Looking at the docs, I haven't been able to figure out if these are the actual messages being sent. Do you know?

Also, is there any way of logging the command name and payload of the operations to the IoT Hub?

gmileka commented 5 years ago

Hi thj-dk, let me look into this on our side and get back to you.

jlian commented 5 years ago

Do you want to log the actual messages themselves (including the content) or do you just want to log the count of messages?

To log the messages themselves, you should use routing to route the messages to storage or something.

To log the count of messages used, enable the "AllMetrics" when turning on the logs:

image

And look for entries for dailyMessageQuotaUsed. You can also directly look for this metric in the portal or API/CLI/PowerShell. Here is the metric you want in the portal, called "Total number of messages used"

image

Check out our docs here https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-metrics

To learn what counts as a "message" against your quota, you'll need to refer to this. https://azure.microsoft.com/en-us/pricing/details/iot-hub/. TL;DR: most features in IoT Hub like twin updates, queries, D2C/C2D messages will count against your quota in 4KB chunks

gmileka commented 5 years ago

Thanks a lot John - thj-dk, John works on the Azure Iot Hub team and I reached out for his help... I'll close this issue for tracking... please, feel free to re-activate if you have further questions.

thj-dk commented 5 years ago

Thank you very much @jlian and @gmileka! This is much appreciated. I'd like to see the actual messages and their contents for debugging purpose, so I'll try and setup routing.