I'm trying to use multiline in Filebeat to parse Java stacktrace as shown below but still have a hard time extracting and grouping all needed data.
[Mon Nov 26 02:58:42 PST 2018] HEARTBEAT count=1 rev=***
PRODUCT- URI: *****
2018-11-26T02:58:57.395-0800: [GC pause]
PRODUCT- URI: *****
[Mon Nov 26 02:58:42 PST 2018] HEARTBEAT count=2 rev=***
PRODUCT- URI: *****
WARNING: ****
[2018-11-26 03:00:33,904] WARN ****
[Mon Nov 26 03:00:33 PST 2018] START: ****
Exception: *****
at ****
at ****
... 139 more
Caused by: ****
... 143 more
END:*****
[Mon Nov 26 03:00:33 PST 2018] START: ****
Exception: *****
at ****
at ****
... 139 more
Caused by: ****
... 143 more
END:*****
Basically, I want to group the most recent HEARTBEAT line and all lines between "START...END" as a single event, anything between HEARTBEAT line and "START" should be dropped.
What I want to get is:
[Mon Nov 26 02:58:42 PST 2018] HEARTBEAT count=2 rev=***
PRODUCT- URI: *****
WARNING: ****
[2018-11-26 03:00:33,904] WARN ****
[Mon Nov 26 03:00:33 PST 2018] START: ****
Exception: *****
at ****
at ****
... 139 more
Caused by: ****
... 143 more
END:*****
[Mon Nov 26 03:00:33 PST 2018] START: ****
Exception : *****
at ****
at ****
... 139 more
Caused by: ****
... 143 more
END:*****
My current filebeat config is:
filebeat.prospectors:
- type: log
paths:
- log.txt
multiline.pattern: '^java.|^[[:space:]]+(at|\.{3})\b|^Caused by:|^END:'
multiline.negate: false
multiline.match: after
processors:
- drop_event:
when:
not:
contains:
message: "START"
contains:
message: "HEARTBEAT"
output.logstash:
hosts: ["localhost:5044"]
When I use the configuration above, I can extract HEARTBEAT line and "START...END" separately but am not able to group them together as a single event. The reason to group the most recent HEARTBEAT line with "START...END" is because I need some fields in HEARTBEAT line to populate the exception instance for each "START...END".
Should I process HEARTBEAT and "START...END" separately and store the "HEARTBEAT" into es index and look up the "HEARTBEAT" from ES when I receive "START...END"? Will it have time delay to retrieve the most recent HEARTBEAT line?
What is the most appropriate way to handle this kinda of stack trace?
Thanks a lot!