The downside of using -o short is that the format is difficult to parse; short-iso better. If you use the ELK stack, exporting it as JSON is even better. A systemd service, such as the following, will be good enough to send JSON logs to a remote host.
[Unit] Description=Send Journalctl to Syslog [Service] TimeoutStartSec=0 ExecStart=/bin/sh -c '/usr/bin/journalctl -o json -f | /usr/bin/ncat syslog 515' Restart=always RestartSec=5s [Install] WantedBy=multi-user.target
On the other hand, logstash.conf for me includes:
input { tcp { port => 1515 codec => json_lines type => "systemd" } } filter { if [type] == "systemd" { mutate { rename => [ "MESSAGE", "message" ] } mutate { rename => [ "_SYSTEMD_UNIT", "program" ] } } }
This makes the entire log data structure available for Kibana / Elasticsearch.
Jc
source share