Splunk Search

Field Extraction with Multiline and Single line mixed

rangarbus
Path Finder

Hi Team:

Here on the Extraction for Event 2, the MESSAGE field is extracted as empty as its not multiline.
How should i extract MESSAGE for both multiline and single line.?

Query:

index=abcd sourcetype=fallback 
| rex field=_raw "^(?P<DATETIME>[^,]+),\d+\s+\[(?P<DAEMON>[^\]]+)\]\s+(?P<SEV>[^ ]+)\s+(?P<CLASS>[^ ]+)\s+\-\s+(?P<MESSAGE>(.*[\r\n]+)*)"
| table DATETIME, DAEMON, SEV, CLASS, MESSAGE

Event 1:

2020-12-07 17:43:02,075 [ABCD_Daemon1] WARN ABCD_CLASS1 - Failed to process
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2048)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)
at db.$EmailNotifierDaemon.run(asdasd.java:1133)

Extracted as:

DATETIME : 2020-12-07 17:43:02
DAEMON: ABCD_Daemon1
SEV: WARN
CLASS: ABCD_CLASS1
MESSAGE: Failed to process
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2048)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:403)
at db.$EmailNotifierDaemon.run(asdasd.java:1133)


Event 2:

2020-12-07 16:12:14,273 [ABCD_Daemon2] INFO ABCD_CLASS2 - Got notification for external configuration change, cleaning caches.

Extracted as:

DATETIME : 2020-12-07 16:12:14
DAEMON: ABCD_Daemon2
SEV: INFO
CLASS: ABCD_CLASS2
MESSAGE:

Thank you

Labels (1)
0 Karma
1 Solution

renjith_nair
Legend

Try adding the new line as not mandatory

change to

(?P<MESSAGE>(.*[\r\n]?+)*)

 

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

Try adding the new line as not mandatory

change to

(?P<MESSAGE>(.*[\r\n]?+)*)

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...