Splunk Search

Can I perform stats count on a substring using regex?

chetan1974
Engager

I have log events such as activity:http://xyz/rest/876
http://xyz/rest/223
http://xyz/rest/263
http://xyz/rest/4534
http://abc/rest/1
when I do stats count by activity I want to get results as:
http://xyz/rest 4
http://abc/rest 1

How can it be best done?

0 Karma
1 Solution

DalJeanis
Legend

Try this:

|  rex "(?<activity>http:\/\/[^\/]*\/rest)" 
| stats count as mycount by activity

View solution in original post

DalJeanis
Legend

Try this:

|  rex "(?<activity>http:\/\/[^\/]*\/rest)" 
| stats count as mycount by activity
Get Updates on the Splunk Community!

Stay Connected: Your Guide to July Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...