Best practice to manage device logs with IoT Hub

Mariachiara Cesario 0 Reputation points
2024-06-05T08:24:05.4066667+00:00

Hello,

I was wondering if there are any best practices for managing logs generated by IoT devices. Currently, our devices generate logs in text files, and we thought the easiest way to manage these logs is to upload the text files to a storage account container using the IoT Hub file upload functionality. Is there a more recommended method for sending logs?

Thank you.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,216 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
654 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. akinbade abiola 20,300 Reputation points
    2024-06-05T08:34:48.0333333+00:00

    Hello Mariachiara Cesario,

    Thanks for your question.

    You can consider using Azure Monitor and Log Analytics to centralize and analyze your logs.

    Please see below:

    https://learn.microsoft.com/en-us/azure/iot-hub/tutorial-use-metrics-and-diags

    https://learn.microsoft.com/en-us/azure/iot-hub/monitor-iot-hub?source=recommendations

    https://learn.microsoft.com/en-us/azure/iot/iot-overview-security'

    Please let me know if you have further questions.

    If the above information was useful, please remember to 'Accept Answer'

    0 comments No comments

  2. Sander van de Velde | MVP 33,636 Reputation points MVP
    2024-06-05T13:03:31.5766667+00:00

    Hello Mariachiara Cesario,

    welcome to this moderated Azure community forum.

    It's hard to say there is one standard. This is related to the kind of device, the amount of logging, kind of connectivity, using the SDK or Azure IoT Edge.

    What I have seen in the past is:

    • Making use of the file upload. Perfect if you use the SDK
    • Making use of sending logging as telemetry. good for incidental logging. You need to fork the telemetry stream from regular telemetry. Keep it small because it eats up a number of IoT Hub messages per day. You could write custom code to turn this on or off via a desired property wil the logging level
    • Using a Direct Method to get a certain amount of logs is seen also. Azure IoT Edge offers this standard via the edgeAgent module
    • Custom logging to a Storage account. You need to exchanging eg. a SAS token to keep the connection secret. Using Azure IoT Edge, Microsoft provides a specific Blob Storage Account module having a data pump towards the cloud.
    • Other Custom logging towards the cloud via eg. an Azure Function or an Event Hub. Again, check out a secure solution for exchanging secrets to keep the connection secure

    The file upload is actually used most. It's flexible and the security is handled by the IoT Hub, no extra logic is needed. With the addition to configure eg. the interval or level using desired properties.


    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.

    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.