<?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 Re: How to edit my search to find the average time duration between 2 events of same transaction id? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322832#M96386</link>
    <description>&lt;P&gt;I would try like this (assuming the field extractions are all working as expected)&lt;BR /&gt;
Requirement 2 - tabular listing of transaction and duration&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
| chart values(_time) over transaction_id by logpoint
| eval duration=coalesce(response_out-request_in,"In Process")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Requirement 1 -  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
| chart values(_time) over transaction_id by logpoint
| eval _time=request_in
| eval duration=coalesce(response_out-request_in,"In Process")
| timechart  avg(duration) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Feb 2017 19:48:47 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-02-22T19:48:47Z</dc:date>
    <item>
      <title>How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322831#M96385</link>
      <description>&lt;P&gt;Below is sample transaction id having multiple events of which 2 specific events are as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
Date_time: 22/02/2017 18:55:51
transaction_id: 87873
component: ula
redirect-url="http://someURL"
logpoint: response_out
}

{  
Date_time: 22/02/2017 18:55:56
transaction_id: 87873
component: ula
request_uri="/xyz"
logpoint: request_in
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If there are millions of such different transactions id's each having the same above 2 events then i need to calculate the avg. time duration between these 2 specific events for same transaction id.&lt;/P&gt;

&lt;P&gt;I have prepared below search but not sure if this gives me the avg. duration between the 2 events of same transaction_id:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC | transaction startswith=(component=ula AND logpoint="response_out" AND redirect-url="http://someURL") 
endswith=(component=ula AND logpoint="request_in" AND request-uri="/xyz")|dedup transaction_id | timechart span=1h avg(duration)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Another requirement is to find data in tabular format giving the time duration between these 2 specific events against the transaction_id in a log of million transaction ids ordered by maximum duration in descending order:&lt;BR /&gt;
Eg.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;transaction_id              duration(in sec)
87873                             5
4323344                        3
7676442                        2
5645625                        1
......
5657354                       0.5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Appreciate a quick response for the 2 searches requested.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 18:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322831#M96385</guid>
      <dc:creator>mayurkadam24</dc:creator>
      <dc:date>2017-02-22T18:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322832#M96386</link>
      <description>&lt;P&gt;I would try like this (assuming the field extractions are all working as expected)&lt;BR /&gt;
Requirement 2 - tabular listing of transaction and duration&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
| chart values(_time) over transaction_id by logpoint
| eval duration=coalesce(response_out-request_in,"In Process")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Requirement 1 -  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
| chart values(_time) over transaction_id by logpoint
| eval _time=request_in
| eval duration=coalesce(response_out-request_in,"In Process")
| timechart  avg(duration) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 19:48:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322832#M96386</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-22T19:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322833#M96387</link>
      <description>&lt;P&gt;Hi Somesh,&lt;/P&gt;

&lt;P&gt;I'm getting below error in splunk for the query shared by you:&lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The expression is malformed. Expected ).&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector. &lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 07:56:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322833#M96387</guid>
      <dc:creator>mayurkadam24</dc:creator>
      <dc:date>2017-02-23T07:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322834#M96388</link>
      <description>&lt;P&gt;What do you get a fields (in statistics tab) when you run following? If the field extraction are working fine, you should get fields, transaction_id, request_in, response_out&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
 | chart values(_time) over transaction_id by logpoint
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322834#M96388</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T13:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322835#M96389</link>
      <description>&lt;P&gt;For Requirement 1, I'm getting O/P in below format which is not the expected O/P. The exepected O/P is given in the question raised. Can you please check if the query is correct ?&lt;/P&gt;

&lt;P&gt;usecase-id                                                                      duration                            request-in               response-out   &lt;/P&gt;

&lt;P&gt;00a9047f-1ea3-4e0e-80e0-d2125125aeec             In Process                1492093827.552             1492093827.793&lt;BR /&gt;
                                                                                                                               1492093827.552              1492093827.793 &lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 15:44:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322835#M96389</guid>
      <dc:creator>mayurkadam24</dc:creator>
      <dc:date>2017-04-13T15:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322836#M96390</link>
      <description>&lt;P&gt;For Requirement 2, I'm getting O/P in below format which is not the expected O/P. The exepected O/P is given in the question raised. Can you please check if the query is correct ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;usecase-id        duration                          request-in               response-out   

00a9047f-1ea3-4e0e-80e0-d2125125aeec   In Process  1492093827.552             1492093827.793
                                                                                                                                                         1492093827.552              1492093827.793 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Apr 2017 15:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322836#M96390</guid>
      <dc:creator>mayurkadam24</dc:creator>
      <dc:date>2017-04-13T15:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to find the average time duration between 2 events of same transaction id?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322837#M96391</link>
      <description>&lt;P&gt;Try this for requirement 2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ABC logpoint="request_in" OR logpoint="response_out"
 | stats max(_time) as end min(-_time) as start by transaction_id
 | eval duration=coalesce(end-start,"In Process")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Apr 2017 16:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-find-the-average-time-duration-between/m-p/322837#M96391</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-13T16:09:19Z</dc:date>
    </item>
  </channel>
</rss>

