Splunk Search

Why does this field extraction and rex give different results?

tfilip
Engager

I'm completely stuck here. I'm trying to extract the "Path" from a logfile with this format:

 

 

Time:	 05/10/2022 11:26:53
Event:  Traffic
IP Address:  xxxxxxxxxx
Description:  HOST PROCESS FOR WINDOWS SERVICES
Path:  C:\Windows\System32\svchost.exe
Message:      Blocked Incoming UDP  -  Source  xxxxxxxxxx :  (xxxx)   Destination  xxxxxxxxxx :  (xxxxx)
Matched Rule:  Block all traffic

 

 

using this regex

 

 

((Path:\s{1,2})(?<fwpath>.+))

 

 

It does exactly what I want when I use rex, it extracts the path as "fwpath". However, when I do it as a field extraction, it matches the rest of the log entry. Why is it behaving differently for these two?

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try this

((Path:\s{1,2})(?<fwpath>\S+))

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try this

((Path:\s{1,2})(?<fwpath>\S+))

tfilip
Engager

That (almost) did it! I had to replace \S with \N so that it wouldn't stop at spaces in paths, like "C:\Program Files".

 

Thanks much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...