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
Super Champion

Try this:

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

View solution in original post

0 Karma

javiergn
Super Champion

Try this:

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

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...