Journal Export Format
- Note that this document describes the binary serialization format of journals only, as used for transfer across the network. For interfacing with web technologies there's the Journal JSON Format. The binary format on disk is documented as Journal File Format. Before reading on, please make sure you are aware of the basic properties of journal entries, in particular realize that they may include binary non-text data (though usually don't), and the same field might have multiple values assigned within the same entry (though usually hasn't).
When exporting journal data for other uses or transferring it via the network/local IPC the journal export format is used. It's a simple serialization of journal entries, that is easy to read without any special tools, but still binary safe where necessary. The format is like this:
- Two journal entries that follow each other are separated by a double newline.
- Journal fields consisting only of characters >= 32 (space) and < 127 (i.e. printable, non-control ASCII) are serialized as they are (i.e. field name, followed by '=', followed by field data), followed by a newline as separator to the next field. Note that fields containing tabs or newlines cannot be formatted like this.
- Other journal fields are serialized in a special binary safe way: field name, followed by newline, followed by a binary 64bit little endian size value, followed by the binary field data, followed by a newline as separator to the next field.
- Entry metadata that is not actually a field is serialized like it was a field, but beginning with two underscores. More specifically,
__MONOTONIC_TIMESTAMP=are introduced this way. Note that these meta-fields are only generated when actual journal files are serialized. They are omitted for entries that do not originate from a journal file (for example because they are transferred for the first time to be stored in one). Or in other words: if you are generating this format you shouldn't care about these special double-underscore fields. But you might find them usable when you deserialize the format generated by us. Additional fields prefixed with two underscores might be added later on, your parser should skip over the fields it does not know.
- The order in which fields appear in an entry is undefined and might be different for each entry that is serialized. And that's already it.
This format can be generated via "journalctl -o export".
Here's an example for two serialized entries which consist only of text data:
[[!format txt """ CURSOR=s=739ad463348b4ceca5a9e69c95a3c93f;i=4ece7;b=6c7c6013a26343b29e964691ff25d04c;m=4fc72436e;t=4c508a72423d9;x=d3e5610681098c10;p=system.journal REALTIME_TIMESTAMP=1342540861416409 MONOTONIC_TIMESTAMP=21415215982 BOOT_ID=6c7c6013a26343b29e964691ff25d04c TRANSPORT=syslog PRIORITY=4 SYSLOG_FACILITY=3 SYSLOG_IDENTIFIER=gdm-password] SYSLOG_PID=587 MESSAGE=AccountsService-DEBUG(+): ActUserManager: ignoring unspecified session '8' since it's not graphical: Success PID=587 UID=0 GID=500 COMM=gdm-session-wor EXE=/usr/libexec/gdm-session-worker CMDLINE=gdm-session-worker [pam/gdm-password] AUDIT_SESSION=2 AUDIT_LOGINUID=500 SYSTEMD_CGROUP=/user/lennart/2 SYSTEMD_SESSION=2 SELINUX_CONTEXT=system_u:system_r:xdm_t:s0-s0:c0.c1023 SOURCE_REALTIME_TIMESTAMP=1342540861413961 MACHINE_ID=a91663387a90b89f185d4e860000001a HOSTNAME=epsilon
CURSOR=s=739ad463348b4ceca5a9e69c95a3c93f;i=4ece8;b=6c7c6013a26343b29e964691ff25d04c;m=4fc72572f;t=4c508a7243799;x=68597058a89b7246;p=system.journal REALTIME_TIMESTAMP=1342540861421465 MONOTONIC_TIMESTAMP=21415221039 BOOT_ID=6c7c6013a26343b29e964691ff25d04c TRANSPORT=syslog PRIORITY=6 SYSLOG_FACILITY=9 SYSLOG_IDENTIFIER=/USR/SBIN/CROND SYSLOG_PID=8278 MESSAGE=(root) CMD (run-parts /etc/cron.hourly) PID=8278 UID=0 GID=0 COMM=run-parts EXE=/usr/bin/bash CMDLINE=/bin/bash /bin/run-parts /etc/cron.hourly AUDIT_SESSION=8 AUDIT_LOGINUID=0 SYSTEMD_CGROUP=/user/root/8 SYSTEMD_SESSION=8 SELINUX_CONTEXT=system_u:system_r:crond_t:s0-s0:c0.c1023 SOURCE_REALTIME_TIMESTAMP=1342540861416351 MACHINE_ID=a91663387a90b89f185d4e860000001a HOSTNAME=epsilon """]] Yupp, no example with binary data here: the wiki can't show this nicely. Sorry.