All Apps and Add-ons

Field Extraction via Regex

raimondo_massar
New Member

Hi
I would like to list below logline in 4 parts and I'm not sure how to do it in with Regex. The automatic field extractor does not work. Any suggestion on how to write the right regex.

Field1  Field2              Field3                                 Field4
[AUDIT] [USER_AUTH_SUCCESS] Authentication successfully completed. User: 'Test'

This is an extract out of the field extractor which is not working:

?:[^[n][){3}(?P<fieldname1>[^]]+)[^ n] [(?P<fieldname2>[^]]+)](?P<fieldname3>s+w+s+w+s+w+.)^(?P<fieldname4>s+w+:)
0 Karma

jonuwz
Influencer

In that case feel free to accept the answer below. Thanks

0 Karma

raimondo_massar
New Member

Perfect ..it works. thanks very much for your help !

0 Karma

jonuwz
Influencer

Here you go :

* | head 1 
| eval message="[AUDIT] [USER_AUTH_SUCCESS] Authentication successfully completed. User: 'Test'"
| table message 
| rex field=message "\[(?<field1>[^]]+)\] \[(?<field2>[^]]+)\] (?<field3>.*)\s+User: '(?<field4>.*?)'"

Everything between the two " on the last line is the regex you need to extract the fields

i.e.

\[(?<field1>[^]]+)\] \[(?<field2>[^]]+)\] (?<field3>.*)\s+User: '(?<field4>.*?)'

raimondo_massar
New Member

it's always information about the user

0 Karma

jonuwz
Influencer

Where does Field4 start ? is it

after a '.'

or

it it always information about the user ?

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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