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 -o json-pretty shows every field of a log entry

Journalctl
~/tips/tip-journalctl-json-pretty-fields

journalctl -u nginx -n 1 -o json-pretty

Prints a full log entry with all its metadata fields, ready for scripting or filtering.

Filtering by field is easy once I know the field names, and one entry shows them all.

journalctl -u nginx -n 1 -o json-pretty
journalctl -u nginx -o json | jq -r .MESSAGE

The first command prints the newest entry of the unit with all its fields, such as _PID, _SYSTEMD_UNIT, PRIORITY and __REALTIME_TIMESTAMP. -o json prints one compact object per line, which pipes into jq. Use the field names for exact matches as in journalctl _PID=1234. Fields with non-printable bytes appear as arrays of numbers, and fields larger than 4096 bytes show as null unless you add --all. Run it once on an entry you care about to learn the names.

Further reading: journalctl manual 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