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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...