<?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: Get elapsed time between two events in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-elapsed-time-between-two-events/m-p/595931#M104067</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/209150"&gt;@politrons&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;did you tried to do all the calculation in one stats?&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; "My event 1" OR "My event 2" 
| stats 
   earliest(eval(if(searchmatch("My event 1"),_time,"")) as time_login 
   latest((eval(if(searchmatch("My event 2"),_time,"")) as time_finish 
   BY transactionId
| eval difference=time_finish-time_login &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the only problem (present also in your solution) is if one of the time_login or time_finish is outside the search time period.&lt;/P&gt;&lt;P&gt;Remember that Splunk isn't a DB, so join command (that all the people coming from SQL used to use) is a command to use only when there isn't any other solution!&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 12:08:43 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-04-29T12:08:43Z</dc:date>
    <item>
      <title>How to get elapsed time between two events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-elapsed-time-between-two-events/m-p/595926#M104066</link>
      <description>&lt;P&gt;I'm trying to calculate the milliseconds between two events by same transactionId, and then show in a timechart&lt;/P&gt;
&lt;P&gt;Here my current query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; "My event 1" | stats latest(_time) as time_login by transactionId |join transactionId [search "My event 2" | stats latest(_time) as time_finish by transactionId] | eval difference=time_finish-time_login &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This query works really slow and half of the time it does not work, but if I try to add this to the end of the query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;| timechart avg(difference)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 17:59:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-elapsed-time-between-two-events/m-p/595926#M104066</guid>
      <dc:creator>politrons</dc:creator>
      <dc:date>2022-04-29T17:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get elapsed time between two events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-get-elapsed-time-between-two-events/m-p/595931#M104067</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/209150"&gt;@politrons&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;did you tried to do all the calculation in one stats?&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; "My event 1" OR "My event 2" 
| stats 
   earliest(eval(if(searchmatch("My event 1"),_time,"")) as time_login 
   latest((eval(if(searchmatch("My event 2"),_time,"")) as time_finish 
   BY transactionId
| eval difference=time_finish-time_login &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the only problem (present also in your solution) is if one of the time_login or time_finish is outside the search time period.&lt;/P&gt;&lt;P&gt;Remember that Splunk isn't a DB, so join command (that all the people coming from SQL used to use) is a command to use only when there isn't any other solution!&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 12:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-get-elapsed-time-between-two-events/m-p/595931#M104067</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-04-29T12:08:43Z</dc:date>
    </item>
  </channel>
</rss>

