Splunk Search

How to Extract value from Source Field

saroj005
Engager

Hi,

I want to Extarct Filed from Source file and Below are some
Sorce file.

/opt/si/logs/taopwssid1/admin/paas-cli.log.07-11-17
/opt/si/logs/umsawssis1/admin/tcmgr.log
/opt/si/logs/saidwssid2/admin/paas-cli.log.07-11-16

I want to extract below value
taopwssid1
umsawssis1
saidwssid2

How Can i Do this through REX.

Tags (1)
1 Solution

skoelpin
SplunkTrust
SplunkTrust

Try this.. It will create a new field called host_name with the extracted fields your looking for

| rex field=source \/opt\/\w+\/\w+\/(?<host_name>\w+)

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

your base search 
| rex field=source "^(\/[^\/]+){3}\/(?<YourFieldName>[^\/]+)"
0 Karma

skoelpin
SplunkTrust
SplunkTrust

Try this.. It will create a new field called host_name with the extracted fields your looking for

| rex field=source \/opt\/\w+\/\w+\/(?<host_name>\w+)

0 Karma
Get Updates on the Splunk Community!

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 ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...