<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to search the average time between request and response when a certain field value is the same? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201501#M58378</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Can someone please help me to calculate the time difference between the request and response when the token is the same?&lt;BR /&gt;
Because its multi threading between request and response, other request and response can exists, so I want to calculate based on time, request and response when token/thread is same. I have bolded the fields&lt;/P&gt;

&lt;P&gt;INFO  | &lt;STRONG&gt;2016-06-09 04:37:29,432&lt;/STRONG&gt; | &lt;STRONG&gt;thread-1&lt;/STRONG&gt; | ApiProviderImpl | &lt;STRONG&gt;request&lt;/STRONG&gt;: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;&lt;STRONG&gt;TOKEN=11&lt;/STRONG&gt;;] OUTPUT[]}&lt;BR /&gt;
INFO  | 2016-06-09 04:37:29,542 |thread-2 | ApiProviderImpl | request: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=22;] OUTPUT[]}&lt;BR /&gt;
INFO  | &lt;STRONG&gt;2016-06-09 04:37:30,415&lt;/STRONG&gt; | &lt;STRONG&gt;thread-1&lt;/STRONG&gt; | ApiProviderImpl | &lt;STRONG&gt;response&lt;/STRONG&gt;: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;&lt;STRONG&gt;TOKEN=11&lt;/STRONG&gt;;] &lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Sarada&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:54:16 GMT</pubDate>
    <dc:creator>saradachelluboy</dc:creator>
    <dc:date>2020-09-29T09:54:16Z</dc:date>
    <item>
      <title>How to search the average time between request and response when a certain field value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201501#M58378</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Can someone please help me to calculate the time difference between the request and response when the token is the same?&lt;BR /&gt;
Because its multi threading between request and response, other request and response can exists, so I want to calculate based on time, request and response when token/thread is same. I have bolded the fields&lt;/P&gt;

&lt;P&gt;INFO  | &lt;STRONG&gt;2016-06-09 04:37:29,432&lt;/STRONG&gt; | &lt;STRONG&gt;thread-1&lt;/STRONG&gt; | ApiProviderImpl | &lt;STRONG&gt;request&lt;/STRONG&gt;: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;&lt;STRONG&gt;TOKEN=11&lt;/STRONG&gt;;] OUTPUT[]}&lt;BR /&gt;
INFO  | 2016-06-09 04:37:29,542 |thread-2 | ApiProviderImpl | request: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=22;] OUTPUT[]}&lt;BR /&gt;
INFO  | &lt;STRONG&gt;2016-06-09 04:37:30,415&lt;/STRONG&gt; | &lt;STRONG&gt;thread-1&lt;/STRONG&gt; | ApiProviderImpl | &lt;STRONG&gt;response&lt;/STRONG&gt;: Transaction Bundle{ &lt;BR /&gt;
INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;&lt;STRONG&gt;TOKEN=11&lt;/STRONG&gt;;] &lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Sarada&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201501#M58378</guid>
      <dc:creator>saradachelluboy</dc:creator>
      <dc:date>2020-09-29T09:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the average time between request and response when a certain field value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201502#M58379</link>
      <description>&lt;P&gt;Hi saradachelluboyena, &lt;/P&gt;

&lt;P&gt;try this &lt;CODE&gt;stats&lt;/CODE&gt; command to get the duration in seconds (this assumes you have a field called &lt;CODE&gt;thread&lt;/CODE&gt; already) :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INFO thread=* TOKEN=* request OR response 
| stats latest(_time) AS latest earliest(_time) AS earliest by TOKEN, thread 
| eval duration = latest - earliest 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Since you have transaction in your log which are not done yet, you can change the search a bit and use &lt;CODE&gt;streamstats&lt;/CODE&gt; to get an additional new &lt;CODE&gt;id&lt;/CODE&gt; field and check against this. &lt;BR /&gt;
I used this as source file to test it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INFO | 2016-06-09 04:31:29,432 | thread-1 | ApiProviderImpl | request: Webpay Transaction Bundle{ INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;TOKEN=72;] OUTPUT[]}
INFO | 2016-06-09 04:32:29,542 |thread-2 | ApiProviderImpl | request: Webpay Transaction Bundle{ INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=91;] OUTPUT[]}
INFO | 2016-06-09 04:33:29,542 |thread-3| ApiProviderImpl | response: Webpay Transaction Bundle{ INPUT[CLIENTID=10000113;JVM_VERSION=1.7.0_21;TOKEN=91;] OUTPUT[]}
INFO | 2016-06-09 04:34:29,542 |thread-2 | ApiProviderImpl | request: Webpay Transaction Bundle{ INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=19;] OUTPUT[]}
INFO | 2016-06-09 04:35:29,542 |thread-3| ApiProviderImpl | response: Webpay Transaction Bundle{ INPUT[CLIENTID=10000113;JVM_VERSION=1.7.0_21;TOKEN=19;] OUTPUT[]}
INFO | 2016-06-09 04:36:30,415 | thread-1 | ApiProviderImpl | response: Webpay Transaction Bundle{ INPUT[CLIENTID=10000111;JVM_VERSION=1.7.0_21;TOKEN=72;]
INFO | 2016-06-09 04:37:29,542 |thread-2 | ApiProviderImpl | request: Webpay Transaction Bundle{ INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=20;] OUTPUT[]}
INFO | 2016-06-09 04:38:29,542 |thread-2 | ApiProviderImpl | request: Webpay Transaction Bundle{ INPUT[CLIENTID=10000112;JVM_VERSION=1.7.0_21;TOKEN=21;] OUTPUT[]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can see that the last two transactions have started but are not yet finished. Also I created a field called &lt;CODE&gt;action&lt;/CODE&gt; which has the value of either &lt;CODE&gt;request&lt;/CODE&gt; or &lt;CODE&gt;response&lt;/CODE&gt;&lt;BR /&gt;
Using this as search source you can run the search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TOKEN=* request OR response 
| streamstats earliest(_time) AS earliest latest(_time) AS latest count(eval(if(action="request" OR action="response", 1, null()))) AS id by TOKEN 
| eval diff=latest-earliest 
| where id&amp;gt;1 | table id TOKEN action _time earliest latest 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the result looks like this:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;removed on request&lt;/EM&gt;&lt;BR /&gt;
As you can see the last two TOKEN will not show up in this search &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 01:44:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201502#M58379</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-06-09T01:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the average time between request and response when a certain field value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201503#M58380</link>
      <description>&lt;P&gt;Assuming you have the Token field extracted, the easiest way would to use the &lt;CODE&gt;transaction&lt;/CODE&gt; command ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    .... | transaction TOKEN startswith=request endswith=response | table TOKEN duration | eval duration=tostring(duration, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you do not have the TOKEN field extracted, add this before the transaction command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   ... | rex "TOKEN=(?&amp;lt;TOKEN&amp;gt;\w+);" | transaction ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2016 01:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201503#M58380</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-09T01:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the average time between request and response when a certain field value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201504#M58381</link>
      <description>&lt;P&gt;Hi Mus,&lt;/P&gt;

&lt;P&gt;I have tried &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INFO TOKEN=* request OR response | stats latest(_time) AS latest earliest(_time) AS earliest by TOKEN | eval duration = latest - earliest | stats count by duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am getting data but that is incorrect &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Sarada.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 00:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201504#M58381</guid>
      <dc:creator>saradachelluboy</dc:creator>
      <dc:date>2016-06-10T00:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the average time between request and response when a certain field value is the same?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201505#M58382</link>
      <description>&lt;P&gt;Well, I showed a way to do it. If the data in not correct it is pretty hard to help in this regard......&lt;BR /&gt;
Why for example do you add another stats in the end and you wanted the session to be based on &lt;CODE&gt;thread&lt;/CODE&gt; and &lt;CODE&gt;TOKEN&lt;/CODE&gt; but you just use &lt;CODE&gt;TOKEN&lt;/CODE&gt;.....&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 01:11:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-average-time-between-request-and-response-when/m-p/201505#M58382</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-06-10T01:11:52Z</dc:date>
    </item>
  </channel>
</rss>

