-
-
Save devynspencer/a421d1c6184f0c69ff99 to your computer and use it in GitHub Desktop.
JSON rsyslog output for Logstash
This file contains hidden or 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
template(name="ls_json" type="list" option.json="on") { | |
constant(value="{") | |
constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339") | |
constant(value="\",\"@version\":\"1") | |
constant(value="\",\"message\":\"") property(name="msg") | |
constant(value="\",\"host\":\"") property(name="hostname") | |
constant(value="\",\"severity\":\"") property(name="syslogseverity-text") | |
constant(value="\",\"facility\":\"") property(name="syslogfacility-text") | |
constant(value="\",\"programname\":\"") property(name="programname") | |
constant(value="\",\"procid\":\"") property(name="procid") | |
constant(value="\"}\n") | |
} |
This file contains hidden or 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
input { | |
udp { | |
port => 10514 | |
codec => "json" | |
type => "syslog" | |
} | |
} | |
filter { | |
# This replaces the host field (UDP source) with the host that generated the message (sysloghost) | |
if [sysloghost] { | |
mutate { | |
replace => [ "host", "%{sysloghost}" ] | |
remove_field => "sysloghost" # prune the field after successfully replacing "host" | |
} | |
} | |
} | |
output { | |
# whatever | |
} |
This file contains hidden or 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
# Other config goes above here... | |
# Include all config files in /etc/rsyslog.d/ | |
$IncludeConfig /etc/rsyslog.d/*.conf | |
# Set the target host here by replacing 127.0.0.1 | |
*.* @127.0.0.1:10514;ls_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment