Splunk Search

Search for value in field after stripping characters

akhanVG
Path Finder

Not sure how best to word the question but below is what I am trying to do - feel free to edit the question header.

We have a list of URLs that are referrals:

e.g.

www.example.com/this-file/doe?a=a
www.example.com/this-file/dane
www.example.com/this-file/doe

URL 1 and URL 3 are in actuality the same, there is just URL params in the first. Is there a method I Can use to strip the URL params before running the search an doing a count? The outcome would be ideally

www.example.com/this-file/doe - 2
www.example.com/this-file/dane - 1

We cannot pre-filter the data using props or inputs.conf. This would have to be done at search run time.

currently our search string is index="test" regex referrer="^http://www.example.com/these-files/*" | stats count by referrer | sort -count

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

Try this

index="test"  referrer="http://www.example.com/these-files/*" 
| rex field=referrer "(?<new_referrer>.*?)\?"
| stats count by new_referrer | sort -count

View solution in original post

aalanisr26
Path Finder

Alternative would be to use regular expression:

index="test" regex referrer="^http://www.example.com/these-files/*" | rex field=referrer "(?.+)\?"
stats count by url | sort -count

0 Karma

lguinn2
Legend

Try this

index="test"  referrer="http://www.example.com/these-files/*" 
| rex field=referrer "(?<new_referrer>.*?)\?"
| stats count by new_referrer | sort -count

aalanisr26
Path Finder

have you try
faup app:
https://splunkbase.splunk.com/app/1545/

this my help you handling urls

akhanVG
Path Finder

Will definitely look into this. @lguinn answer did it for me so far though - thanks!

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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