Open fredlahde opened 2 years ago
PS: The /entries
endpoint also supports a Range Header, aswell as a follow
mode. Both of which could be used to deal with units which log a lot of stuff.. Always fetching everything is maybe not desirable from a performance standpoint.
Maybe we can remember the __CURSOR
of the last entry we got and only request new entries
I was researching ways to read the
systemd
journal programmatically and it turns out,systemd-journal-gatewayd
exists.This is a
systemd
service itself, which can be installed on ubuntu via the systemd-journal-remote package.Once installed, it listens on
0.0.0.0:19531
per default and, among others, exposes the/entries
endpoint. Using theAccept: application/json
header, we get the following JSON per log line:We already have
type: journal
andunit: foobar
config directives, with which we can easily filter down this JSON for a specificsystemd
Unit, and with__REALTIME_TIMESTAMP
we can also support thefrom_ms
query-parameterMore info about
systemd-journal-gatewayd
can be found here: https://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html