Access to Container Logs (PubNub) from other container



I need to read the logs from one container into other container.

The idea is parse this logs and analize some messages to hook some actions.

Currently we run FFMPEG into 2 containers, for transcoding, a know issue with FFMPEG is when Internet connection go down, ffmpeg don’t detect this and only show a message into the logs “av_interleaved_write_frame() broken pipe” our idea is listen for this message into one of the containers and hook the restart of the encoder to fix them using Resin API. Some advice to do something like this?


In general you can programmatically read any container’s logs from any device using the resin SDK - - but that won’t actually work for your case, since it goes via the Resin API, so fails as soon as the device’s internet connection does down.

You could directly talk to Docker (really, Balena) on the device to get the logs. You can mount the Balena socket with the io.resin.features.balena-socket label, which will expose the socket for the device’s Balena instance at /var/run/balena.sock in the container. One of our getting started examples for multicontainer users this to monitor & expose Docker metrics from within a container itself: You can use that to directly read the logs through Docker, and then parse them however you’d like.

I wouldn’t go for either of those approaches though. Instead, I’d pipe the ffmpeg process in your containers through another process in the same container that can parse the output and check for this, and then expose that information to other containers in a more manageable & flexible way. Perhaps that could ping a webhook in another container, expose that info via a status endpoint from the ffmpeg container, or use any other mechanism you like. That gives you a clear interface, rather than coupling one container to the exact log format of another, which will make this all a little more maintainable in future.