Created
April 12, 2017 17:23
-
-
Save wrouesnel/418fc39f70f04ad2ab56b099c6955540 to your computer and use it in GitHub Desktop.
rsyslog for structured output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module(load="imfile" mode="inotify") | |
input(type="imfile" | |
Tag="log" | |
File="/run/*.log" | |
Ruleset="applogs" | |
addMetadata="on") | |
template(name="jsonfmt" type="list") { | |
property(name="timegenerated" dateformat="rfc3339") | |
constant(value=" ") | |
property(name="$!service") | |
constant(value=" : ") | |
property(name="msg") | |
constant(value="\n") | |
} | |
ruleset(name="applogs") { | |
set $!service=re_extract($!metadata!filename, "(.*)/([^/]*)", 0, 2, "unknown"); | |
action(type="ompipe" Pipe="/proc/1/fd/1" template="jsonfmt") | |
stop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment