Splunk Search

How to capture multiline events (with a regex)?

skender27
Contributor

Hi,

I am trying to capture the multiline events from a Weblogic-similar log which satisfies all three conditions below:
- start with "Entering Strategy" string
- contains at least one [ACTIVE]
- finish with "Exiting strategy" string

I experimented with the regex101 (Python syntax), but I always get unclear results...

[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)': Entering strategy : PRESCORE : Jun 19, 2015 9:58:12 AM
[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)': IN : Setup (Process Flow Object)
[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)':  IN : Setup (Perform Process)
[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)':    IN : Activation Modules (Segmented Process. Exiting strategy)
[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)'
[ACTIVE] ExecuteThread: '31' for queue: 'weblogic.kernel.Default (self-tuning)':...
...

Any suggestions?

Thanks a lot,
Skender Kollcaku

Tags (3)
0 Karma

woodcock
Esteemed Legend

Use this in your props.conf:

[yourSourceTypeHere]
SHOULD_LINEMERGE=false
LINE_BREAKER = ([\r\n]+)\[[^\r\n]*?Entering\s+strategy
MUST_BREAK_AFTER = Exiting\s+strategy\)(?=[\r\n])

Then you need to deploy it to your indexers (or Heavy Forwarders) and restart each Splunk instance before it will take effect. You might also look into sending the "other" events into nullQueue; what you have done so far simply detaches them from the events you would like to keep but they still exist as their own separate events:

http://docs.splunk.com/Documentation/Splunk/6.2.4/Forwarding/Routeandfilterdatad

BTW, this is also where you would trigger your 3rd requirement ("contains at least one [ACTIVE]") which the props.conf does not include. You just send those without "[ACTIVE]" to nullQueue, too.

0 Karma

maciep
Champion

not sure if you're just trying to do a field extraction or actually index the data? But maybe something like this is helpful?

(?<thread>Entering strategy[\s\S]+\[ACTIVE\][\s\S]+Exiting strategy)
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...