Splunk Search

rex regex to extract first folder name from the path

sim_tcr
Communicator

Hello,

My source filed has value such as,

*/icsws/log/INSTANCE1/was/base/icsws_ca_server/SystemOut.log*
/icsws*/log/INSTANCE1/ihs/access_log
/wcics
/log/INSTANCE1/ihs/access_log
...
...
*

I would like to extract the first folder names (icsws*, wcics) from above to field named VAH.
can someone help me complete *
| rex field=source ".."**

Thanks,
Simon Mandy

Tags (2)
0 Karma
1 Solution

javiergn
SplunkTrust
SplunkTrust

Try this:

| rex field=source "^/(?<first_folder>[^/]+)"

View solution in original post

0 Karma

javiergn
SplunkTrust
SplunkTrust

Try this:

| rex field=source "^/(?<first_folder>[^/]+)"
0 Karma
Get Updates on the Splunk Community!

Splunk Lantern | Getting Started with Edge Processor, Machine Learning Toolkit ...

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

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...