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!

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...