Add cloud logging to Azure IoT Edge

Azure IoT Edge is an interesting platform for Edge computing. It opens up a lot of new scenarios for local computing as an extension of the Azure cloud. And the combination is both secure and flexible due to the usage of open (security) standards.

But it’s still in Public Preview so once in a while things go sour. Either no messages arrive at in the cloud or local logic is not executed. So this means you have to log into your Edge device (remember to always have a backup plan) and check out the local logging.

But what if I could check out the logging right within Azure?

I came across this Github gem to make Azure IoT Edge local logs available in Azure! And it only takes 15 minutes or less.

“This repository provides an Azure IoT Edge module that can be used to send container logs from other modules on the edge device, including the edge runtime, securely to Azure Log Analytics in the cloud. “

It makes use of some Azure logging resources already available:

The github page has a very good manual on how to add logic this to your running Edge device:

  • Create a Log Analytics source in your resource group:

  • Remember the Linux Workspace ID and Key:

Note: there is no need for further actions like downloading agents etc.

  • Add a new Linux module “veyalla/logspout-loganalytics:linux-amd64” to your IoT Edge (with an arbitrary name)

Note: check out the documentation regarding the JSON in the Container Create Options field (to be entered on the creation of this module).

Once deployed, after a few minutes, the logging of all modules starts to arrive in the cloud.

Using Log Analytics

Let’s check out how we can read the logging. Open the portal and go to Log Analytics:

Click Overview.

In Overview, select Analytics:

A new tab in the browser is opened. Note: if needed, you have to repeat your credentials. This opens https://portal.loganalytics.io:

Finally, open a new query and fill in the one that is suggested:

Now we see the logging of the tempSensor module.

You can further dig into the logging using these query examples provided.

Filtering

And yes, the tempSensor is pretty chatty so our logging is also filled with a lot of messages quickly.

This is also true for the Modbus module. This one shows a logging line for every operation. So this can become a lot of logging too.

The author Venkat Yalla contacted me regarding filtering. See the FAQ for adding additional filtering on the stdout and stderr container logs. It seems it’s even possible to filter on certain module names too.

Conclusion

If you are interested in sending your logging from the edge to cloud, and you are using Linux containers, this is the right solution for you. But keep in mind, every logging line is sent to the cloud if you do not add filtering.

Advertenties