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!

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Splunk App for Anomaly Detection End of Life Announcement

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...