Splunk Search

splunk search

foysal0124
Explorer

 

I have an event value like this  2021-02-15 18:07:33,936, where the last value after comma(936) means the response time in ms. i tried to extract that value and want to average response time but it did not work.

how i can extract the value after comma from that field. i tried something like this 

avg(mvindex(split(TimeStamp,","),-1)) as AverageResponse

TimeStamp=2021-02-15 18:07:33,936

 

Best Regards

Foysal

Labels (1)
0 Karma

foysal0124
Explorer

awesome, it worked

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @foysal0124,

you can extract the values between commas using a regex and then calculate average using the stats command, something like this:

Your_search
| rex ",(?<response_time>\d+),"
| stats avg(response_time) AS average

if in your logs there's the possibility to have also other numbers between commas, you have to use a just a little more complex regex like this:

Your_search
| rex "^\d+-\d+-\d+\s+\d+:\d+:\d+,(?<response_time>\d+),"
| stats avg(response_time) AS average

that you can test at https://regex101.com/r/q4VyFQ/1

Ciao.

Giuseppe

foysal0124
Explorer

awesome test tool, thanks

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @foysal0124,

You use rex command like below;

| rex field=TimeStamp "\,(?<AverageResponse>\d+)"
If this reply helps you an upvote and "Accept as Solution" is appreciated.

foysal0124
Explorer

awesome, it worked, thanks for ur help

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...