-
-
Save MAS150MD200/528c0dcffffa0c883a1c8315fb5ed009 to your computer and use it in GitHub Desktop.
logstash grok filter for Elasticsearch logs
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
filter { | |
if [type] == "elasticsearch" { | |
grok { | |
match => [ "message", "\[%{TIMESTAMP_ISO8601:timestamp}\]\[%{DATA:severity}%{SPACE}\]\[%{DATA:source}%{SPACE}\]%{SPACE}(?<message>(.|\r|\n)*)" ] | |
overwrite => [ "message" ] | |
} | |
if "_grokparsefailure" not in [tags] { | |
grok { # regular logs | |
match => [ | |
"message", "^\[%{DATA:node}\] %{SPACE}\[%{DATA:index}\]%{SPACE}(?<short_message>(.|\r|\n)*)", | |
"message", "^\[%{DATA:node}\]%{SPACE}(?<short_message>(.|\r|\n)*)" ] | |
tag_on_failure => [] | |
} | |
grok { # slow logs | |
match => [ "message", "took\[%{DATA:took}\], took_millis\[%{NUMBER:took_millis}\], types\[%{DATA:types}\], stats\[%{DATA:stats}\], search_type\[%{DATA:search_type}\], total_shards\[%{NUMBER:total_shards}\], source\[%{DATA:source_query}\], extra_source\[%{DATA:extra_source}\]," ] | |
tag_on_failure => [] | |
add_tag => [ "elasticsearch-slowlog" ] | |
} | |
date { # use timestamp from the log | |
"match" => [ "timestamp", "YYYY-MM-dd HH:mm:ss,SSS" ] | |
target => "@timestamp" | |
} | |
mutate { | |
remove_field => [ "timestamp" ] # remove unused stuff | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment