Logspout is not getting logs from other containers.

I created a sample project for this study.

docker-compose.yml

version: '2'
services:
  frontend:
    build: ./frontend
    depends_on:
      - logspout
  logspout:
    build: ./logspout
    ports:
      - "80:80"
    labels:
      io.balena.features.balena-socket: 1

frontend/index.js

...
setInterval(function() {console.log("WHY!!")}, 1000)

↓ balena console

↓ curl logspout logs

The frontend service logs are not output on logspout. Instead, the resin_supervisor logs is output.

Of course, if it is not balena, there is no problem.

docker-compose -f docker-compose.mac.yml up

image

image

How can I get logs from other containers? (even if I don’t use logspout?)
Can I get logs of other containers from docker.sock?

Hi Kazu,

Here is an example on how you can use the supervisor API to fetch logs and store them either to a file, or use a cloud service to keep logs: https://github.com/balena-io-playground/device-cloud-logging. Here is an example using Datadog: https://github.com/balena-io-playground/balena-datadog. Let me know if those examples help, and if we can help further. Thanks!

Hi sradevski,

The device-cloud-logging sample solved my problem. Thank you.

However, I thought that balena.sock could get logs of other containers, isn’t it?
I tried to get logs in Logspout, but it was the same as balena-engine.sock (only resin-supervisor logs).

Hi,

I tried the following:
I deployed your application, current master (https://github.com/kazuph/balena-logspout-sample/commit/14a5392206635165dd31f7e1a112aaee4e0a5c26) to a RPI3. After sshing into the logspout container, I ran the following in the console:

/ > env | grep DOCKER_HOST
DOCKER_HOST=unix:///var/run/balena-engine.sock
/ > apk add curl
...
/ > curl --unix-socket /var/run/balena-engine.sock http:/docker/containers/a17330a55c861cbdc372b872a4e4413fed682fe6d908dbe4df945b0
98a23edcc/logs?stdout=true

This curl command printed:

....
WHY!!
WHY!!
WHY!!
WHY!!
WHY!!

(a17330a55c861cbdc372b872a4e4413fed682fe6d908dbe4df945b0
98a23edcc) is the ID of the frontend container on that device.

So I would guess that there is something wrong in logspout somewhere, since the balena socket would be delivering the logs.

I hope this helps.