Skip to content

Instantly share code, notes, and snippets.

@daniellavoie
Last active January 29, 2023 08:24
Show Gist options
  • Save daniellavoie/43e25d1fb74bc99dc3915a03901777e2 to your computer and use it in GitHub Desktop.
Save daniellavoie/43e25d1fb74bc99dc3915a03901777e2 to your computer and use it in GitHub Desktop.
Logstash grok filter for Logback Logger used by Spring Boot applications
input {
file {
path => /tmp/application.log
codec => multiline {
pattern => "^(%{TIMESTAMP_ISO8601})"
negate => true
what => "previous"
}
}
}
filter {
if [message] =~ "\tat" {
grok {
match => ["message", "^(\tat)"]
add_tag => ["stacktrace"]
}
}
grok {
match => [ "message",
"(?<timestamp>%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME}) %{LOGLEVEL:level} %{NUMBER:pid} --- .+? :\s+(?<logmessage>.*)"
]
}
date {
match => [ "timestamp" , "yyyy-MM-dd HH:mm:ss.SSS" ]
}
mutate {
remove_field => ["message"]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "daniel-app-%{+YYYY.MM.dd}"
document_type => "daniel-app"
}
}
@Dragas
Copy link

Dragas commented Apr 17, 2020

You are god among men.

@cuongnh1998
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment