Splunk Search

Field extracting using Regex

satishsdange
Builder

I am trying to extract username & password from below event -

form_key=6LgmjzGyzOYLIf11&login[username]=dev_lee@gmail.com&login[password]=password&send= 

I am able to extract password properly but for username I am getting dev_lee%40gmail.com instead of precise email ID.
Below is my regex

login.*?username.*?=(?<splUsername>.*?)&.*?login.*?password.*?=(?<splPassword>.*?)&

Could someone please help me fix the problem.

Tags (1)
0 Karma
1 Solution

esix_splunk
Splunk Employee
Splunk Employee

Try this in addition to the urldecode..

.. | rex field=_raw "login\[username\]\=(?<username>[^\&]+)\&login\[password\]\=(?<password>[^&]+)\&send" | eval mail=urldecode(username) | ..

That should fix you up.

View solution in original post

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

Try this in addition to the urldecode..

.. | rex field=_raw "login\[username\]\=(?<username>[^\&]+)\&login\[password\]\=(?<password>[^&]+)\&send" | eval mail=urldecode(username) | ..

That should fix you up.

0 Karma

Sebastian2
Path Finder

Looks like your event is url encoded. Have you tried to decode it? Try using the buildin urldecode?
When searching your data you could use it like:

... | eval mail = urldecode(mail) | ...
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...