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 and TLS: It doesn't have to be too hard

Overview Creating a TLS cert for Splunk usage is pretty much standard openssl.  To make life better, use an ...

Faster Insights with AI, Streamlined Cloud-Native Operations, and More New Lantern ...

Splunk Lantern is a Splunk customer success center that provides practical guidance from Splunk experts on key ...

Splunk Enterprise Security: Your Command Center for PCI DSS Compliance

Every security professional knows the drill. The PCI DSS audit is approaching, and suddenly everyone's asking ...