Splunk Search

Extract field from Filepath

teco_akelly
Engager

I've got a number of files coming from directories similar to this....

C:\File Transfer\Relay Files\8Series_files\WB-CWP\WB_CWP8_869\evt.txt

I'd like to extract the WB_CWP8_869 and create it as a searchable field. The filepath always looks like this.... the section before the field I want varies....

But the beginning (C:\File Transfer\Relay Files\8Series_files\) and the end (evt.txt) is always the same.

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @teco_akelly,

if you're sure that the beginning and the end of your file path is always the same, you can use a regex like this:

C:\\File Transfer\\Relay Files\\8Series_files\\(?<your_field>[^\\]+)\\WB_CWP8_869\\evt\.txt

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

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Operationalizing TDIR: Building a More Resilient, Scalable SOC

Optimizing SOC workflows with a unified, risk-based approach to Threat Detection, Investigation, and Response ...

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...

Raise Your Skills at the .conf25 Builder Bar: Your Splunk Developer Destination

Calling all Splunk developers, custom SPL builders, dashboarders, and Splunkbase app creators – the Builder ...