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!

Observability | How to Think About Instrumentation Overhead (White Paper)

Novice observability practitioners are often overly obsessed with performance. They might approach ...

Cloud Platform | Get Resiliency in the Cloud Event (Register Now!)

IDC Report: Enterprises Gain Higher Efficiency and Resiliency With Migration to Cloud  Today many enterprises ...

The Great Resilience Quest: 10th Leaderboard Update

The tenth leaderboard update (11.23-12.05) for The Great Resilience Quest is out &gt;&gt; As our brave ...