Splunk Search

How to extract file name from the below raw data?

danroberts
Explorer

Hello, 

Can anyone help me to extract the below file name which is OU_..... from the below raw data. 

12:04:19.85 14/09/2023 directory="E:\data\Test" ECHO is off.

Volume in drive E is Data Volume Serial Number is 7808-CA1B

Directory of E:\data\Test 13/09/2023 13:22

<DIR> XXX\xxxx . 13/09/2023 13:22 <DIR> xxx\xxx .. 12/09/2023 09:31 95 xxx\xxx  dir_details.bat 13/09/2023 13:41 171 xxx\xxx  dir_details_copy.bat 07/09/2023 13:26 0 xxx\xxx  edsadsad.txt 07/09/2023 13:26 22 xxx\xxx  OU_kljdajdklsajkdl.zip 07/09/2023 13:26 22 xxx\xxx  OU_kljdajdklsajkewew.zip 07/09/2023 13:26 22 xxx\xxx  OU_kljdajdklsajkewewdsads.zip 6 File(s) 332 bytes 2 Dir(s) 20718067712 bytes free

 

splunk.PNG

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this:

| rex max_match=0 "\s+\S+\s+\S+\s+\S+\s+\S+\s+(?<file>OU_\S+)"

In future, please paste the text of your event into a code block </> much like I have done with the SPL above. This prevents the text from being reformatted and losing spaces and new lines etc.

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this:

| rex max_match=0 "\s+\S+\s+\S+\s+\S+\s+\S+\s+(?<file>OU_\S+)"

In future, please paste the text of your event into a code block </> much like I have done with the SPL above. This prevents the text from being reformatted and losing spaces and new lines etc.

0 Karma

danroberts
Explorer

Thanks for the rely, this has worked. 

Would this also work in a props.conf file ? 

I'm utilising a universal forwarder with a bat script to pull the data from the directory. 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @danroberts ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @danroberts,

please try this:

| rex "(?<filename>OU_\w*\.\w*"

that you can test at https://regex101.com/r/UiiMSA/1

Ciao.

Giuseppe

0 Karma

danroberts
Explorer

Thanks for the reply, unfortunately this just pulls out one of the OU file names. 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @danroberts,

please try this:

| rex max_match=0 "(?<filename>OU_\w*\.\w*"

Ciao.

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This is what you asked for

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...