Splunk Search

How do I extract part of a URI and store this string as a new field so I can run statistics on it?

belesni
New Member

Hi!

I need to extract part of a uri and store this string in a field to run statistics on it.
http://www.something.com/i_need_this_part/etc-etc-etc

For example:
htp://ww.something.com/first/etc-etc-etc
htp://ww.something.com/second/etc-etc-etc
htp://ww.something.com/first/etc-etc-etc

name      count
first       2
second      1

I don't know if it's possible, but if it is, then please let me know how I can extract this part of the uri and run statistics on it! Thank you

Ps: I intentionally made error in the links because i dont have enough karma to post links

0 Karma

jspears
Communicator

If you have your sourcetype as access_combined_wcookie or access_common, Splunk automatically extracts that URI segment as a field called "root".

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi belesni,

based on your provided events you can try something like this:

your base search here | rex "\/(?<myURI>\w+)\/" | stats count by myURI

If this is what you're looking for, setup the regex as automatic field extraction - read more about this in the docs http://docs.splunk.com/Documentation/Splunk/6.2.2/Knowledge/ExtractfieldsinteractivelywithIFX

Hope this helps ...

cheers, MuS

Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...