Splunk Search

Extract Part of Field

IRHM73
Motivator

Hi, I wonder whether someone could help me please.

I'm trying to extract a particular value from a field which is "file-upload-ready". I can manage to exclude the value but not to extract it.

This is and example of the data string:

/country-private/file-upload-ready/1d555d59-9b5f-4877-bc76-2597142e1964/9011be92-6a1b-46a6-9e56-48dfdbf36c24

Many thanks and kind regards

Chris

Tags (2)
0 Karma
1 Solution

koshyk
Super Champion

hi,
Can you please try (assuming second block in your data is what you want)

|makeresults | eval myString="/country-private/file-upload-ready/1d555d59-9b5f-4877-bc76-2597142e1964/9011be92-6a1b-46a6-9e56-48dfdbf36c24"| rex field=myString "\/.+?\/(?<fileStatus>.+?)\/"

https://regex101.com/r/CvfqNH/1

View solution in original post

0 Karma

koshyk
Super Champion

hi,
Can you please try (assuming second block in your data is what you want)

|makeresults | eval myString="/country-private/file-upload-ready/1d555d59-9b5f-4877-bc76-2597142e1964/9011be92-6a1b-46a6-9e56-48dfdbf36c24"| rex field=myString "\/.+?\/(?<fileStatus>.+?)\/"

https://regex101.com/r/CvfqNH/1

0 Karma

IRHM73
Motivator

Many thanks @koshyk.

Regards

Chris

0 Karma

kunalmao
Communicator

you can do it by using rex command,

search .... | rex field=your_field "\/(?\w+-\w+)\/"

just verify the reg ex once.

0 Karma

IRHM73
Motivator

Hi @kunalmaom thank you for this, but unfortunately this doesn't extract any data.

Many thanks and kind regards

Chris

0 Karma

kunalmao
Communicator

obviously it won't , the regex is not correct 😛

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...