Splunk Search

How do I edit my search to remove specific substrings from URI values in my results in statistics tab?

manjunathin
New Member

I wrote a search which gives the result below in the statistics tab:

URI Count   
HTTPS://XXXXXXXX//AAAA.aspx%3FUIC=GuidID=8090443C5BA5ED33%26_SecEntityType=1%26BID=71E160E1E55478D5 1   
HTTPS://XXXXXXXX/CCCCC.aspx?UIC=GuidID%3d952932873084A530%26_SecEntityType%3d1&BID=9B387A4FD720BD78     1   
HTTPS://XXXXXXXX//AAAA.aspx                                                                                     2   
HTTPS://XXXXXXXX/CCCCC.aspx     2   

However, I was looking for a way to remove the data after .aspx and have the count included in statistics.
I'm expecting the statistics to look like:

URI                        Count    
HTTPS://XXXXXXXX//AAAA.aspx     3   
HTTPS://XXXXXXXX/CCCCC.aspx     3   
0 Karma
1 Solution

javiergn
Super Champion

Hi,

Regex101 is your friend here.
Try this:

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:\/\/.+\.aspx)"
| stats count by shortUri

This is what I used to test your example: https://regex101.com/r/dU4sD7/2

If you have multiple aspx files try using a negative lookahead in your regex.
The following matches all your examples:

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:\/\/(?:(?!\.aspx).)*\.aspx)"
| stats count by shortUri

Third option as provided by @alemarzu below is as follows (simpler than mine using a lazy operator):

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:.*?\.aspx)"
| stats count by shortUri

View solution in original post

javiergn
Super Champion

Hi,

Regex101 is your friend here.
Try this:

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:\/\/.+\.aspx)"
| stats count by shortUri

This is what I used to test your example: https://regex101.com/r/dU4sD7/2

If you have multiple aspx files try using a negative lookahead in your regex.
The following matches all your examples:

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:\/\/(?:(?!\.aspx).)*\.aspx)"
| stats count by shortUri

Third option as provided by @alemarzu below is as follows (simpler than mine using a lazy operator):

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:.*?\.aspx)"
| stats count by shortUri

manjunathin
New Member

Thanks, i tried this but for few URI have
HTTPS://AAAAA.aspx?UIC=_SecEntityType%3d1%26CallerEduId%3d%26SSr%3d%26Target%3d..%252f..%252fDesktop...

which is getting added.

Can we have filter set to first aspx? and have the count included for it?

0 Karma

javiergn
Super Champion

If you have multiple aspx files try using a negative lookahead in your regex.
The following matches all your examples:

| yoursearch
| rex field=URI "(?i)(?<shortUri>^http[s]?:\/\/(?:(?!\.aspx).)*\.aspx)"
| stats count by shortUri
0 Karma

alemarzu
Motivator

Made a change on javiergn regex, try this one.

(?i)(?<shortUri>^http[s]?:.*?\.aspx)
0 Karma

manjunathin
New Member

Perfect...Thanks much.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...