Splunk Search

How to list content between two strings from RAW text?

akapoor47
New Member

Here is the raw text - 

com.companyname.package: stringstart e-38049e11-72b7-4968-b575-ecaa86f54e02 stringend for some.datahere with status FAILED, Yarn appId application_687987, Yarn state FINISHED, and Yarn finalStatus FAILED with root cause: samppleDatahere: com.packagenamehere: Forbidden (Service: Amazon S3; Status Code: 403; Error Code: 403 Forbidden; Request ID: sjhdjksdn


Need to list down the uuid which is in between stringstart and stringend 

Labels (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well, you need to simply find something between your "anchors". Which in simplest form might just be

stringstart\s(?<uuid>.*)\sstringend

If you know that the uuid has some particular form you can be a bit more specific (for example not to capture wrongly formed uuid)

stringstart\s(?<uuid>[0-9a-f]-[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})\sstringend

You can even add more anchoring text in front or at the end if you have more constant parts.

So as you have a regex matching and extracting this part, you can - depending on your use case - either use it as @marnall showed with rex command or use it to define a search-time extraction. For example

EXTRACT-uuid = stringstart\s(?<uuid>[0-9a-f]-[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})\sstringend
0 Karma

marnall
Motivator

I am not sure specifically what you want to do, but if you have that _raw data in an event, and you would like to extract the uuid into a field, then you can make a regex with a named capture group in the rex command to extract it during search time. If you would like this to be permanent then you can copy the regex into a Field Extraction.

<yoursearch>
| rex field=_raw "com.companyname.package: (stringstart\s)?(?<uuid>\S+) (stringend )?for"

I made the assumptions that there are no space characters in the uuid string, and that it is surrounded by "com.companyname.package: and "for"

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...