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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...