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!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...