Splunk Search

How to calculate response time from logs?

ajaynaralikar
New Member

I want to calculate response time from my logs for all records and our application logs in below format,

19-02-2018 23:02:04:371 [RetrieveCompanyData][INFO ]: |BEM_Gateway_Request_MF Request Processing Summary(TransactionId-GCP_708425245) SCVT Recieved Request at 19-02-2018 23:02:04:367
19-02-2018 23:02:15:017 [RetrieveCompanyData][INFO ]: |BEM_Gateway_Response_MF Request Processing Summary(TransactionId-GCP_708425245) SCVT sent response back to consumer at 19-02-2018 23:02:15:015
so can you provide query to for this

0 Karma

somesoni2
Revered Legend

Try like this. You can remove those rex statements if the fields are already extracted.

your base search for selecting only the request and response events
| rex "Recieved Request at (?<request>\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}\.\d{3})"
| rex "sent response back to consumer at (?<response>\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}\.\d{3})"
| rex "TransactionId-(?<transactionId>[^\)]+)"
| stats values(request) as request values(response) as response by transactionId
| convert mktime(request) mktime(response) timeformat="%d-%m-%Y %H:%M:%S.%3N" 
| eval responseTime=response-request
0 Karma

ajaynaralikar
New Member

I tried and I got result in below format. But I want one more column which will show (response-request) result

transactionId   request                     response

1 GCP_198253791 21-02-2018 08:13:32:045 21-02-2018 08:13:35:049
2 GCP_218300826 21-02-2018 08:22:25:047 21-02-2018 08:22:29:177
3 GCP_221454910 21-02-2018 08:06:52:611 21-02-2018 08:06:53:412

0 Karma

mhoogcarspel_sp
Splunk Employee
Splunk Employee

The eval at the end gives you the responseTime field that has that information, should just be there if you're not filtering fields after the eval, sounds like you might be filtering it out somewhere though?

Add this to the end for a bit of formatting/filtering:
| table transactionId responseTime request response

0 Karma

ajaynaralikar
New Member

I tried and got below result.
transactionId request response
1 GCP_198253791 21-02-2018 08:13:32:045 21-02-2018 08:13:35:049
2 GCP_218300826 21-02-2018 08:22:25:047 21-02-2018 08:22:29:177
3 GCP_221454910 21-02-2018 08:06:52:611 21-02-2018 08:06:53:412

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...