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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...