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!

App Building 101 - Build Your First App!

WATCH RECORDING NOW   Tech Talk: App Dev Edition Splunk has tons of out-of-the-box functionality, and you’ve ...

Introducing support for Amazon Data Firehose in Splunk Edge Processor

We’re excited to announce a powerful update to Splunk Data Management with added support for Amazon Data ...

The Observability Round-Up: September 2024

What’s up Splunk Community! Welcome to the latest edition of the Observability Round-Up, a monthly series in ...