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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...