IoT Hub query by text in docker logs

Omar Navarro 331 Reputation points
2022-09-01T18:21:18.577+00:00

Does IoT Hub have built-in functionality to query logs by text? Or Would an additional service like Log Analytics be the best approach to carry out queries across all logs?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
598 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,272 questions
{count} vote

Accepted answer
  1. Sudipta Chakraborty 1,116 Reputation points
    2022-09-01T19:42:43.873+00:00

    @Omar Navarro :

    To view these logs, you must create a diagnostic setting to send them to a destination. One such destination is Azure Monitor Logs, which are collected in a Log Analytics workspace.

    Reference:
    https://learn.microsoft.com/en-us/azure/iot-hub/tutorial-use-metrics-and-diags#collect-logs-for-connections-and-device-telemetry

    After collecting the logs, you will need to run Kusto query against Azure Monitor Logs to observe any errors that occurred.

    Reference:
    https://learn.microsoft.com/en-us/azure/iot-hub/tutorial-use-metrics-and-diags#view-azure-monitor-logs

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2022-09-01T21:56:23.38+00:00

    Hello @Omar Navarro ,

    Azure IoT modules have logging as seen on the device itself using

    iotedge logs -f --tail 100 [modulename]  
    

    These logs can also be read in the cloud using edgeAgent direct methods like 'ping' and 'RestartModule' and 'GetModuleLogs'.

    If you use the Azure portal to look up modules in a device, check out the 'Troubleshoot' button.

    This brings you to a page where you can see the current logging of the selected module, download the logging, or restart the module:

    237047-image.png

    The logs cannot be queried directly. You need to access the logging based on a certain timespan.

    From there, you can do whatever you want with the logging you got.

    You need a live connection to the device, offline devices do not offer access to log files.

    Getting logs is not done for free, it will be counted as part of the daily amount of messages you can exchange for your IoT Hub (1 unit of the S1 tier offers 400.000 daily messages of size 4KB).

    ---

    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. By doing so, all community members who have a similar issue will benefit. Your contribution is highly appreciated.

    1 person found this answer helpful.
    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.