Logs from supervisor api

Hey!

I have been trying to setup some sort of logging on my device and sending them to GCP logging.
Have been using the bash script shown in the github.com/balena-io-examples/device-cloud-logging project witch works fine.
Now I just have some log messages that are just arrays filled with seemingly random integers.

Log Example

{
“_SYSTEMD_CGROUP”:"/system.slice/resin-supervisor.service",
“SYSLOG_FACILITY”:“3”,
“_SYSTEMD_INVOCATION_ID”:“d053202a7c9346549ce4a3340906f502”,
“__MONOTONIC_TIMESTAMP”:“2011690225”,
“_EXE”:"/bin/bash.bash",
“_TRANSPORT”:“stdout”,
“_PID”:“2079”,
“MESSAGE”:[
91,
27,
91,
51,
51,
109,
119,
97,
114,
110,
27,
91,
51,
57,
109,
93,
32,
32,
32,
32,
73,
103,
110,
111,
114,
105,
110,
103,
32,
117,
110,
115,
117,
112,
112,
111,
114,
116,
101,
100,
32,
111,
114,
32,
117,
110,
107,
110,
111,
119,
110,
32,
99,
111,
109,
112,
111,
115,
101,
32,
102,
105,
101,
108,
100,
115,
58,
32,
99,
111,
110,
116,
97,
105,
110,
101,
114,
78,
97,
109,
101
],
“_MACHINE_ID”:“e6226f008f02413fa78a3393743bf404”,
“SYSLOG_IDENTIFIER”:“resin-supervisor”,
“__CURSOR”:“s=b18bd4a1869749c4b2a3e2bebd083646;i=1371;b=c71420df184e4b98ae88b565cc6ce7fb;m=77e7f4f1;t=5c07b25313131;x=759167a71932a39f”,
“_BOOT_ID”:“c71420df184e4b98ae88b565cc6ce7fb”,
“_SYSTEMD_UNIT”:“resin-supervisor.service”,
“_SYSTEMD_SLICE”:“system.slice”,
“_STREAM_ID”:“bd9401226222478e9dfc662edc30dbb5”,
“_UID”:“0”,
“PRIORITY”:“6”,
“_COMM”:“start-resin-sup”,
“_CAP_EFFECTIVE”:“3fffffffff”,
“__REALTIME_TIMESTAMP”:“1619010021044529”,
“_HOSTNAME”:“725129b”,
“_GID”:“0”,
“_CMDLINE”:"/bin/sh /usr/bin/start-resin-supervisor"
}

The log file almost only contain logs like this.

Hoping anyone have experienced this before or got a clue to why these are generated.

/Drak

I’m a bit embarrassed to say that the answer what simply that the log message is in ASCII.

To followup questions
1: Anyway to get the supervisor to not use ASCII? Have been working without the conversion.
2: Anyway to get the containers name in the log from the supervisor? container_name in the docker compose does work, but the supervisor will complain about a unsupported field

The logs are expected to be UTF-8 and as containers might log non-ASCII there cannot be any guarantees that it’s only ASCII.
If you use the curl [1] as described in [2] you need to parse the service name yourself e.g. from the [name] tags.

[1] curl -X POST -H "Content-Type: application/json" --no-buffer --data '{"follow":true,"all":true,"format":"short"}' "$BALENA_SUPERVISOR_ADDRESS/v2/journal-logs?apikey=$BALENA_SUPERVISOR_API_KEY"
[2] device-cloud-logging/save-logs.sh at master · balena-io-examples/device-cloud-logging · GitHub

Alternatively you can use this API to get it as a JSON:
curl --no-buffer "$BALENA_SUPERVISOR_ADDRESS/v2/local/logs?apikey=$BALENA_SUPERVISOR_API_KEY"
as defined in Interacting with the balena Supervisor - Balena Documentation

hope this helps!

It did help. Thanks a lot for your time :slight_smile: