Splunk Search

Regex Help for special characters

chanukhya
Explorer

Hi,

My log looks like this. I am trying to get the average response time by service.

ServiceInvoker (service_A) : executeFlow : Time Take is = 3378
ServiceInvoker (service_B) : executeFlow : Time Take is = 378
ServiceInvoker (service_C) : executeFlow : Time Take is = 338

Here is what i have:

 index=app  |rex '\ServiceInvoker\s+"((?<service>\S+))"\s+:\s+executeFlow\s+:\s+Time\s+take\s+is\s+=\s+(?<response_time>\d+)'   | stats  sparkline(avg(response_time),1m) as processTime_trend, avg(response_time),count BY service 

The brackets that are surrounding the service name is causing an issue for retrieving the results. Any help or ideas would be appreciated.
Thanks in advance

0 Karma
1 Solution

gokadroid
Motivator

Try this:

index=app 
|rex field=_raw "(.*|^)ServiceInvoker\s*\((?<service_name>[^\)]+)\)\s*.*Time\s*Take\s*is\s*\=\s*(?<respTime>[\d]+)"
| stats  sparkline(avg(respTime),1m) as processTime_trend, avg(respTime),count BY service_name

See here the regex in action

View solution in original post

lakromani
Builder

Do you need all the line in the regex? If not, you can do like this:

index=app  | rex "Time Take is =\s(?<respnse_time>\d+)"  | stats  sparkline(avg(response_time),1m) as processTime_trend, avg(response_time),count BY service 
0 Karma

gokadroid
Motivator

Try this:

index=app 
|rex field=_raw "(.*|^)ServiceInvoker\s*\((?<service_name>[^\)]+)\)\s*.*Time\s*Take\s*is\s*\=\s*(?<respTime>[\d]+)"
| stats  sparkline(avg(respTime),1m) as processTime_trend, avg(respTime),count BY service_name

See here the regex in action

aljohnson_splun
Splunk Employee
Splunk Employee

Hi @Chanukhya,

Just escape the ( with a backslash.

https://regex101.com/r/BTBkvw/1

ServiceInvoker\s+\((?<service_name>\w+)\)\s+:\s+(?<service_flow>\w+)\s+:[^=]+=\s(?<response_time>\d+)
0 Karma

chanukhya
Explorer

Sorry, It didn't work. Updated my question.

0 Karma

sundareshr
Legend

Try this

*UPDATED

index=app  |rex "[^\(]+\((?<servicename>[^\)]+)\)[^=]+=[\s\t]+(?<response_time>\d+)"  | stats  sparkline(avg(response_time),1m) as processTime_trend, avg(response_time),count BY service

*OR*

index=app  |rex "[^\(]+\((?<servicename>[^\)]+)" | rex "=[\s\t]+(?<response_time>\d+)"  | stats  sparkline(avg(response_time),1m) as processTime_trend, avg(response_time),count BY service

chanukhya
Explorer

Thanks for your help.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Remember to put backslash before =
Bye.
Giuseppe

0 Karma

chanukhya
Explorer

Sorry, It didn't worked.

0 Karma

sundareshr
Legend

Try the updated query

0 Karma

chanukhya
Explorer

It didn't worked as well, The service names are different and some service names has an underscore in the name and some dont. I am trying to get the average response times and count for each service, which is in between the brackets.

0 Karma

sundareshr
Legend

Do you see any results when you try this

index=app  | rex "[^\(]+\((?<servicename>[^\)]+)\)[^=]+=[\s\t]+(?<response_time>\d+)"  | table servicename response_time
0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...