brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl -N lists every field name your journal uses

Journalctl
~/tips/tip-journalctl-fields-list

journalctl -N | sort

See which field names exist before you write a match on the journalctl command line.

Matches like _SYSTEMD_UNIT= are great once you know the field name. Nobody remembers them all, and the journal can list them for you.

-N, long form --fields, prints every field name that appears in the journal files you can read:

journalctl -N | sort

On a typical box that gives a list with _PID, _COMM, _TRANSPORT, _SYSTEMD_SLICE, _KERNEL_SUBSYSTEM, SYSLOG_IDENTIFIER and a few dozen more. Fields with a leading underscore are trusted fields that journald adds itself, so a program cannot fake them. The rest come from the program that logged the line.

In my view it pairs best with -F. First find a name with -N, then list the values that field has taken, then filter on one of them:

journalctl -N | grep -i kernel
journalctl -F _KERNEL_SUBSYSTEM
journalctl _KERNEL_SUBSYSTEM=usb -b

The list depends on who runs it. As a normal user outside the systemd-journal group you only see fields from your own journal, so run it with sudo if a field you expect is missing. Some fields, like INVOCATION_ID, only show up because systemd itself wrote them about a unit.

Further reading: journalctl man page, systemd.journal-fields man page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link