Splunk Search

Regex help

khajaforu
New Member

Hey Guys,

I need help to write a regex with the name upload to pull the number 3712 from the below log where 'B Sent' is ending string for all the logs.

Upload log: Successfully sent file '\servername\Projects\Cdfad\Prod\51327426.xml' (3712 B sent)

Similarly regex with the name Download to pull the number 152 from the below log (152 B received) where B received is ending

Download log: Successfully stored file at '\servername\Projects\FOI\QA\MassUpdates\F000' (152 B received)

Thank you in advance for your help.

Tags (2)
0 Karma

jconger
Splunk Employee
Splunk Employee

Something like this should work:

\((?<my_field>.*)\sB\ssent\)$

Explanation:

\( matches the '(' character
(?<my_field>.*) is the capture group
\s matches a space
B matches 'B'
\s matches a space
\) matches the ')' character 
$ anchors the regex to the end of the line

Similarly, this should work for your other example:

\((?<my_field>.*)\sB\sreceived\)$
0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...