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!

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...

Understanding Generative AI Techniques and Their Application in Cybersecurity

Watch On-Demand Artificial intelligence is the talk of the town nowadays, with industries of all kinds ...