Splunk Search

How to extract a word between two words?

spatt
New Member

stream=stdout 9 INFO [DataEnrichmentController] (default task-597) start : comm-uuid : rsvp-service : nljnj42343n43k

stream=stdout 4 INFO [DataEnrichmentController] (default task-760) start : commID : rsvp-service : nk324kjln4kj34

stream=stdout 4 INFO [DataEnrichmentController] (default task-760) start : comm-uuid : rsvp-service : vflijiopjoe1442kljn;k23

I want to extract the highlighted word from above log lines

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Alternatively, you can count the separators, like this

| eval myfield = mvindex(split(_raw), " : "), 2)
Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @spatt,

please try this regex:

| rex "start\s+:[^:]*:\s+(?<your_field>[^:]*)"

or this one:

| rex field=stream "start\s+:[^:]*:\s+(?<your_field>[^:]*)"

that you can test at https://regex101.com/r/lWKlbK/1

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...