Splunk Search

How do you extract a string from field _raw?

mukesh2019
Explorer

Hi ,

I am trying to extract info from the _raw result of my Splunk query. Currently my _raw result is:

_raw="ServiceOperation=Hudson_RetrivePatientNot|Broker_HostName=CHELSEA|RequestDateTime=20190113T03:02:18.209400|MessageTranID=**8bfa95c4170911e9b1740a099a2b0000**|UserID=A123|AppID=AERO|ExecGrpName=xxxxxx|TimeStamp=2019-01-13T03:02:28.364605|Message="RetrievePatientFailure"|Detail="RetreivePatientNotes""

I would like to extract the MessageTranID, which in this case is '8bfa95c4-1709-11e9-b174-0a099a2b0000', from the above _raw string.

Something like : base search | regex

Can anyone help?

Thanks so much!

Tags (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi mukesh2019,
try this regex:

\|MessageTranID\=(?<MessageTranID>[^\|]*)

You can test it at https://regex101.com/r/rsBith/1

Bye.
Giuseppe

View solution in original post

0 Karma

vnravikumar
Champion

Hi @mukesh2019

Please try this:

| rex field=_raw "MessageTranID\=(?P<MessageTranID>(.*))\|UserID\="

gcusello
SplunkTrust
SplunkTrust

Hi mukesh2019,
try this regex:

\|MessageTranID\=(?<MessageTranID>[^\|]*)

You can test it at https://regex101.com/r/rsBith/1

Bye.
Giuseppe

0 Karma

mukesh2019
Explorer

Thanks a lot.it works 🙂

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...