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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...