Logs in BalenaOS

Alright. We can close this then.
To recap: Local mode API (i.e. the NDJSON one) works only when your app is in development mode, and the non-local mode API (i.e. the one that listens to journald) is not yet fully in production, but would be (hopefully) by the time the next guy/girl reads this.

Honestly though, despite the mishap here, your guys’ support is remarkable. Thank you!

Hi,
are the logfiles read with

journalctl

persisted across reboot?
Also, this is a command to run locally in the device, right? If so, in order to read logs remotely the SDK is more viable solution, right?
thanks

Hi @banto-78 the logs are only persisted over reboot if you set the “persistent logging” device configuration setting (found on the Actions page). This will allow one to see past boots on the hostOS using journalctl. For reading the logs remotely or storing them in the container you can use the supervisor API mentioned here: https://www.balena.io/docs/reference/supervisor/supervisor-api/#journald-logs

Hi @tomgs can you tell me how you manage to run BalenaOS-in-contianer.
I have try ./balenaos-in-container.sh --image balenalib/raspberrypi3-64-alpine-node -c config.json, but I got:
Status: Downloaded newer image for balenalib/raspberrypi3-64-alpine-node:latest
INFO: Running balenaOS as container balena-container-21248 …
WARNING: Localhost DNS setting (–dns=127.0.0.2) may fail in containers.
can’t run ‘/sbin/openrc’: No such file or directory
can’t run ‘/sbin/openrc’: No such file or directory
can’t run ‘/sbin/openrc’: No such file or directory
can’t run ‘/sbin/openrc’: No such file or directory

And I have search over DockerHub didn’t find balenaOS Docker Image from Balenalib. Should I build the balenaOS docker image myself, or there is another way?

I am new with balena. Anything is apprecated, please.

Hello @weijie ,
These messages are only warnings, your container is running. You can check it with docker ps.

@zvin thanks for you reply! I can see the container is running, but it seen there is noting inside, like balenaEngine or balena-supervisor. Is it suppose to be like that, or there are ways I can setup balenEngine and balena-supervisor?

Hi,
How did you come to the conclusion that there is nothing running inside the container?
Kind regards,
Theodor

I have run / # ps
PID USER TIME COMMAND
1 root 0:00 {init} /usr/bin/qemu-aarch64 /sbin/init
29 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty1
31 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty2
32 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty3
33 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty4
34 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty5
35 root 0:00 {getty} /usr/bin/qemu-aarch64 /sbin/getty 38400 tty6
63 root 0:00 {sh} /usr/bin/qemu-aarch64 /bin/sh
70 root 0:00 {/bin/ps} /bin/ps

Right, what does systemctl --no-pager say?

ONe of my colleagues just pointed you are using a balena base-image and you are supposed to use a balenaOS base image. Try using this image resin/resinos:2.44.0_rev1-intel-nuc with the command.

I would like to follow up on this:

Is there another way to translate the container ids to container names other than bind-mounting the balena socket into a container? Bind mounting the socket into the container provides a bit more privileges to the container than I would like to give it. Without the names the logs are much less useful since we cannot see or filter which service created it.

Hi, I think you can use the supervisor API to request that information: https://www.balena.io/docs/reference/supervisor/supervisor-api/#get-v2statestatus

Thanks,
Zahari

Ah, cool. That solves it. Thx