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!

Splunk is Nurturing Tomorrow’s Cybersecurity Leaders Today

Meet Carol Wright. She leads the Splunk Academic Alliance program at Splunk. The Splunk Academic Alliance ...

Part 2: A Guide to Maximizing Splunk IT Service Intelligence

Welcome to the second segment of our guide. In Part 1, we covered the essentials of getting started with ITSI ...

Part 1: A Guide to Maximizing Splunk IT Service Intelligence

As modern IT environments continue to grow in complexity and speed, the ability to efficiently manage and ...