balena logs show warning only

Hi,

In the Balena dashboard, I want to output all the (last 1000?) warning log messages in the HostOS terminal.

I looked in:

balena logs --help and in journalctl – help.

Probably something like this: journalctl -f -n 1000 -a -u balena but then with an extra option to output warning lines only.

How can I print the warning log messages only?

Persistent logging is enabled and devices is rebooted afterwards.

Thanks

Hi,

Have you looked at the journalctl option --priority (-p)?
I think this should do what you want.
From the man pages:

Filter output by message priorities or priority ranges. Takes either a single numeric or textual log level (i.e. between 0/“emerg” and 7/“debug”), or a range of numeric/text log levels in the form FROM…TO. The log levels are the usual syslog log levels as documented in syslog (3), i.e. “emerg” (0), “alert” (1), “crit” (2), “err” (3), “warning” (4), “notice” (5), “info” (6), “debug” (7). If a single log level is specified, all messages with this log level or a lower (hence more important) log level are shown. If a range is specified, all messages within the range are shown, including both the start and the end value of the range. This will add “PRIORITY=” matches for the specified priorities.

Read more at: journalctl linux command man page

Try for example journalctl -f -n 1000 -a -u balena -p warning