Splunk Search

How to extract a field from a long path name?

splunker9999
Path Finder

HI

We need to create a new field for file name and this is to be extracted from path we have.

We need to extract last segment from below path which is jst_cat_20170119164505.xfrfrom below path .
Format of path is as below

/home/ist/user/dealer/jst_cat_20170119164505.xfr
/home/dlr/user/ist_cat_20116091456.xfr.pdt
/home/dlr/user/ist_cat/dealer/files.20160910.txt
/home/dlr/user/ist_cat/dealer/files.20160910.txt.pdt

Thanks

0 Karma

gokadroid
Motivator

If all of these urls are in individual events then this extraction shall give you desired result:

your command to return events
| rex "\/(([^\s\/]+\/)*)(?<fileName>[\S]+)"
| table fileName

If all of these are in single event then use the max_match=0 something like this

your command to return events
| rex max_match=0 "\/(([^\s\/]+\/)*)(?<fileName>[\S]+)"
| mvexpand fileName
| table fileName
0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...