Skip to content

Instantly share code, notes, and snippets.

@hrchu
Last active July 19, 2018 08:55
Show Gist options
  • Save hrchu/0be91f843b9b99df0bc8 to your computer and use it in GitHub Desktop.
Save hrchu/0be91f843b9b99df0bc8 to your computer and use it in GitHub Desktop.
logstash grok filter pattern to extract (root) "Caused by:" from java stack trace
com.xx.Exception: java.io.FileNotFoundException
at org.apache.cxf.jaxrs.JAXRSInvoker.handleFault(JAXRSInvoker.java:324)
...
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200)
... 46 more
Caused by: com.xx.WrongSizeException: blahblah
... 64 more
input {
log4j {
mode => "server"
host => "127.0.0.1"
port => 9527
type => "log4j"
}
}
filter {
if [type] == "log4j" {
grok {
match => [ "stack_trace", "(?!.*Caused by:)by: %{NOTSPACE:caused_by}"]
}
}
}
output {
#...
}
com.xx.WrongSizeException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment