Splunk Search

help with a REGEX

extreme1
New Member

I need help with a REGEX that needs to extract just fourth field in a line and nothing else.
The event looks like this:
Switch : 800471-00-04 1215G-04161 xxxxx xxxxx xxxx ........

Al I need is the "1215G-04161" portion of that line Can someone give me a quick regex for that?

Thanks!

Tags (1)
0 Karma

eashwar
Communicator

if you want the field for all events which start with the word Switch

EXTRACT-field4= (?i)Switch\s+:\s+\S+\s+(?P<4field>\S+-\S+)

eashwar
Communicator

instead of 4field replace your own name! which you like to give

0 Karma

eashwar
Communicator

index=main sourcetype="tcp-raw" | rex "(?i)Switch\s+:\s+\S+\s+(?P<4field>\S+-\S+)"

try this bro!!
consider voting if the answers helped you!!
thanks in advance!!
happy splunking,

0 Karma

extreme1
New Member

Thanks. So what would the actual search look like?
==> index=main sourcetype="tcp-raw" | rex ????

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Assuming each field is a block of non-spaces, and assuming each field is separated by spaces, you can do this:

^(\S+\s+){3}(?<field4>\S+)
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...