What I have done:
I have enabled multiline pattern in filebeat.yml file:
multiline.pattern: '^[[:space:]]+|^Caused by:'
multiline.negate: false
multiline.match: after
My sample log file contains multiline exceptions:
Exception in thread "main" java.lang.IllegalStateException: A book has a null property
at com.example.myproject.Author.getBookIds(Author.java:38)
at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
Caused by: java.lang.NullPointerException
at com.example.myproject.Book.getId(Book.java:22)
at com.example.myproject.Author.getBookIds(Author.java:35)
... 1 more
Exception in thread "main" java.lang.NullPointerException
at com.example.myproject.Book.getTitle(Book.java:16)
at com.example.myproject.Author.getBookTitles(Author.java:25)
at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
From filebeat logs I can see that these multiline exceptions are getting parsed properly:
2017-05-15T08:21:36-07:00 DBG Publish: {
"@timestamp": "2017-05-15T15:21:31.768Z",
"beat": {
"hostname": "WIN-UV5OA3SO3LF",
"name": "WIN-UV5OA3SO3LF",
"version": "5.2.0"
},
"input_type": "log",
"message": "Exception in thread \"main\" java.lang.IllegalStateException: A book has a null property\n at com.example.myproject.Author.getBookIds(Author.java:38)\n at com.example.myproject.Bootstrap.main(Bootstrap.java:14)\nCaused by: java.lang.NullPointerException\n at com.example.myproject.Book.getId(Book.java:22)\n at com.example.myproject.Author.getBookIds(Author.java:35)\n ... 1 more",
"offset": 409,
"source": "C:\\Filebeat\\test\\testLog.txt",
"type": "log"
}
2017-05-15T08:21:41-07:00 DBG Publish: {
"@timestamp": "2017-05-15T15:21:31.768Z",
"beat": {
"hostname": "WIN-UV5OA3SO3LF",
"name": "WIN-UV5OA3SO3LF",
"version": "5.2.0"
},
"input_type": "log",
"message": "Exception in thread \"main\" java.lang.NullPointerException\n at com.example.myproject.Book.getTitle(Book.java:16)\n at com.example.myproject.Author.getBookTitles(Author.java:25)\n at com.example.myproject.Bootstrap.main(Bootstrap.java:14)",
"offset": 669,
"source": "C:\\Filebeat\\test\\testLog.txt",
"type": "log"
}
Problem:
- Multiline events parsed by filebeat is not getting tagged as multiline.
- Due to this my grok filter on logstash is not able to treat it accordingly
if "multiline" in [tags] {
grok {
match => ["message", "%{JAVASTACKTRACEPART}"]
}
}
Any pointers will be appreciated!