Splunk Search

Extract numerical value from text logs and get max occurrence of the number

vinayakolhapure
Engager

I want to extract a number from logs where the line of interest looks like,

INFO 2020-11-16 12:11:47,161 [ThreadName-1] com.mypackage.myclass TransId: a12345b6-7cde-8901-2f34-g5hi6jk789l0 Req ID - 123456 EvNum-1234567 - Received 12 create/cancel request.

I want to extract all occurrences for the number (in this example 12) between "Received " and " create/cancel request." for a time range and get the max. Basically to get what is the largest request the app received.

Thank you for your help with this.

Labels (4)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I like to use rex for this purpose.

... | rex "Received (?<requestCount>\d+)"
| stats max(requestCount) as largestRequest
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

I like to use rex for this purpose.

... | rex "Received (?<requestCount>\d+)"
| stats max(requestCount) as largestRequest
---
If this reply helps you, Karma would be appreciated.

vinayakolhapure
Engager

Thank you. This helps a lot and gives me a great starting point to explore further.

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...