Splunk Search

What is the regular expression that will get the servlet name in a URL?

rbathla
New Member

Taking an example below, I am looking to be make a regular expression that will give me name of servlet form below (after last slash and first question mark).

URL:
/shop/mystore/ProductDisplay?urlRequestType=Base

Result:
ProductDisplay

Tags (1)
0 Karma

gokadroid
Motivator

try this if say your url is in field myField

your query to return the events
| rex field=myField "\/([^\/]+\/)*(?<servlet>[^\?]+)\?.*"
| table servlet

See regex at work here

If the field is not already extracted then try it generally with or without string field=_raw in below query:

your query to return the events
| rex field=_raw  "\/([^\/]+\/)*(?<servlet>[^\?]+)\?.*"
| table servlet
0 Karma
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 ...