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 --output-fields keeps JSON output to the fields you name

Journalctl
~/tips/tip-journalctl-output-fields-limit-json

journalctl -o json --output-fields=MESSAGE,PRIORITY -n 3

Limits JSON or verbose output to the fields you list, which keeps scripts small and fast.

A full JSON entry has dozens of fields, and most scripts need two.

--output-fields= takes a comma separated list. It works with the formats that normally print everything, such as json, verbose and export, and with cat. The cursor, the timestamps and the boot ID are always included for JSON, so you can still order and identify the entries.

journalctl -o json --output-fields=MESSAGE,PRIORITY -n 3

With -o cat the listed fields are printed value by value, one per line. That is handy for a quick check, but awkward when you have several fields.

Further reading: journalctl(1) 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