Splunk Search

field extraction

Nadhiya_Dubai
Explorer

/data/scripts/esx/outfile/dc1-ch1-esxi05.dca.com-vmnic0.txt

I need to extract the dc1-ch1-esxi05.dca.com-vmnic0 from the above string . How can i write regex for this .

Tags (1)
0 Karma
1 Solution

gf13579
Communicator
(?<server_and_interface>[^\/]+)\.txt$

Here it is in action:

| makeresults | eval source="/data/scripts/esx/outfile/dc1-ch1-esxi05.dca.com-vmnic0.txt" | rex field=source "(?<server_and_interface>[^\/]+)\.txt$"

View solution in original post

vnravikumar
Champion

Hi

Give a try

| makeresults 
| eval path="/data/scripts/esx/outfile/dc1-ch1-esxi05.dca.com-vmnic0.txt" 
| rex field=path "(?P<temp>.*(?=\.))" 
| rex field=temp "(?P<output>[^\/]+$)"
0 Karma

gf13579
Communicator
(?<server_and_interface>[^\/]+)\.txt$

Here it is in action:

| makeresults | eval source="/data/scripts/esx/outfile/dc1-ch1-esxi05.dca.com-vmnic0.txt" | rex field=source "(?<server_and_interface>[^\/]+)\.txt$"

Nadhiya_Dubai
Explorer

It worked . Thanks

0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...