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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...