Last active
October 18, 2019 11:01
-
-
Save dterziev/a17ee41de0761af1a95a to your computer and use it in GitHub Desktop.
Logstash 2.1.x config for log4net logs.
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
input { | |
file { | |
path => ".../Logs/*.log" | |
type => "log4net" | |
sincedb_path => ".../since.db" | |
codec => multiline { | |
pattern => "^%{TIMESTAMP_ISO8601} " | |
negate => true | |
what => previous | |
} | |
# start_position => "beginning" - does not work with the codec in logstash 2.1 | |
} | |
} | |
filter { | |
grok { | |
match => ["path", "(?<filename>[^/]+?)(-\[(?<processid>\d+)\])?\.log" ] | |
add_field => [ "process", "%{host}:%{processid}" ] | |
} | |
if [type] == "log4net" { | |
grok { | |
match => ["message", "%{TIMESTAMP_ISO8601:timestamp} \[%{NUMBER:threadid}\] %{WORD:level}\s*%{DATA:class} %{DATA:NDC} - %{GREEDYDATA:message}"] | |
overwrite => ["message","timestamp"] | |
} | |
date { | |
match => ["timestamp","yyyy-MM-dd HH:mm:ss,SSS"] | |
remove_field => ["timestamp"] | |
} | |
grok { | |
match => [ "message", "(?<message>[^\r\n]*)\r?(\n(?<exception>.*))?"] | |
overwrite => ["message"] | |
} | |
} | |
kv { | |
trim => "\r\(\)" | |
trimkey => "\r\(\)" | |
source => "message" | |
# target => "props" | |
value_split => ":" | |
allow_duplicate_values => false | |
} | |
mutate { | |
convert => { | |
"processid" => "integer" | |
"threadid" => "integer" | |
"Elapsed" => "integer" | |
"ItemId" => "integer" | |
} | |
} | |
} | |
output { | |
elasticsearch { | |
hosts => [ "127.0.0.1:9200" ] | |
template_overwrite => true | |
} | |
stdout { codec => rubydebug } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment