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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...