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.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...