Splunk Enterprise

how to write Regex for matching two strings with numbers

james_n
Path Finder

Hi,

I have a data like

event 1 classA Total number of calls happened: 1104

event 2 ClassA Marked the calls in finalization: 1111

event 3 classA Total number of calls happened: 10

So, i would like to write regex for matching two fields one for string and another for number in all events

Expected output:

Transactions count

Total number of calls happened 1114

Marked the calls in finalization 1111

Tags (1)
0 Karma

woodcock
Esteemed Legend

Like this:

| makeresults | eval raw="classA Total number of calls happened: 1104:::classA Marked the calls in finalization: 1111:::classA Total number of calls happened: 10"
| fields - _time
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex "^(?<class>\S+)\s+((?:Total number of calls happened:\s*(?<happened>\d+))|(?:Marked the calls in finalization:\s*(?<finalized>\d+)))$"
| stats sum(*) AS * BY class
0 Karma

FrankVl
Ultra Champion

Try something like this:

| rex "(?:c|C)lassA\s(?<Transactions>[^:]):\s(?<count>\d+)"
| chart sum(count) as count over Transactions
0 Karma

james_n
Path Finder

if it is StateImpl_CCC Total number of calls happened 1114 instead of classA Total number of calls happened: 1104 ??

0 Karma

FrankVl
Ultra Champion

Try | rex "\w+\s(?<Transactions>[^:]):\s(?<count>\d+)"

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...