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
Revered Legend

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!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...