Getting Data In

Extract part of string

sarit_s
Communicator

Hello

 

I have this source path for example :

 

AAN831AA_ELS_Log_20200102064858+0000-[PS-MELSPP2]/fsmLog_010220-064856_4C5KKM00_AAN831AA.txt

 

and i want to extract the part before '-'
 

 

AAN831AA_ELS_Log_20200102064858+0000

 

 what should i do ?

 

thanks

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

For a search-time extraction, use rex.

| rex "(?<field>[^-]+)"

For an index-time extraction, put this in transforms.conf and reference it in props.conf.

[extractField]
REGEX = (?<field>[^-]+)

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

For a search-time extraction, use rex.

| rex "(?<field>[^-]+)"

For an index-time extraction, put this in transforms.conf and reference it in props.conf.

[extractField]
REGEX = (?<field>[^-]+)

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...