Splunk Search

Regex expression

xvxt006
Contributor

Hi

I have events like this and i am using the below expression to extract the command before query string.

sourcetype="access_combined_wcookie" host=prlws*  | rex field=uri "(?P<command>\w+)" | top limit=50 command

But it is capturing gcom as it has . after gcom.suggestions.json. Is there way to capture the whole thing meaning gcom.suggestions.json

167.234.83.253 - - [16/Jul/2013:17:47:44 -0500] "GET /gcom.suggestions.json?selectedText=5GKA2*&start=0&count=Infinity HTTP/1.1" 200 

167.234.83.254 - - [16/Jul/2013:17:47:52 -0500] "GET /GenericController?action=getSecurityToken&domain=new.grainger.com&_=1374014869039 HTTP/1.1" 200
Tags (1)
0 Karma
1 Solution

gfuente
Motivator

Hello

Try with this regex:

...| rex field=uri "(?P< command >(\w+|\.)+)" | ...

*Remove blanks before and after command

Regards

View solution in original post

0 Karma

gfuente
Motivator

Hello

Try with this regex:

...| rex field=uri "(?P< command >(\w+|\.)+)" | ...

*Remove blanks before and after command

Regards

0 Karma

xvxt006
Contributor

Thank you. It worked !!!

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...