<?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 calculate duration in seconds between two events? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206903#M40846</link>
    <description>&lt;P&gt;Then you would need to extract the file EventName to contain these string and then show them in the table. To help you with that, please post some sample data.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2015 15:40:24 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-09-08T15:40:24Z</dc:date>
    <item>
      <title>How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206898#M40841</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a log file in which there are two events "Sending reply for message" and "reply message sent". Both are sharing the same time stamp in logs in this format (mm-dd hh:mm:ss). Now I want to calculate the age in seconds between these two events. My search is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" sourcetype="xyz" | transaction startswith="Sending reply for message" endswith="reply message sent" | table host duration _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which is giving the result like given below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host        duration       _time
sc-pet-cif   0   2015-08-31 21:50:37
sc-pet-cif   0   2015-08-31 21:48:30 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is giving by host, but I want to show the both calculated events in the output with the duration, not host, so please help me out.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 13:11:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206898#M40841</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-08T13:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206899#M40842</link>
      <description>&lt;P&gt;You're getting two events in the output means you're transaction is not being applied. WHat is the expected output?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 14:06:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206899#M40842</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-08T14:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206900#M40843</link>
      <description>&lt;P&gt;I want both the events name in output. The output generated from my above given query, giving the exact duration after subtracting the time between two events but instead of host i want to show the events name in output so how could I do that?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 14:36:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206900#M40843</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-08T14:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206901#M40844</link>
      <description>&lt;P&gt;i believe that transaction is being applied. the OP said both events share the same timestamp. that why the duration of the transaction is 0 and for the looks of it, he has 2 transactions. the table command is just showing host duration _time and not the rest of the _raw&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 15:14:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206901#M40844</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2015-09-08T15:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206902#M40845</link>
      <description>&lt;P&gt;can you post some sample data?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 15:22:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206902#M40845</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2015-09-08T15:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206903#M40846</link>
      <description>&lt;P&gt;Then you would need to extract the file EventName to contain these string and then show them in the table. To help you with that, please post some sample data.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 15:40:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206903#M40846</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-08T15:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206904#M40847</link>
      <description>&lt;P&gt;We can manufacture a sessionID using streamstats like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" sourcetype="xyz" | reverse | eval new_session=if(match(_raw,"Sending reply for message"),"TRUE",null()) | streamstats current=t count(new_session) AS sessionID BY host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now each host's events have a sessionID field that can be used to distinguish/group events that can be exploited by tacking on something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats earliest(_raw) AS first latest(_raw) AS last earliest(_time) AS start latest(_time) AS stop BY host sessionID | eval durationSeconds = stop - start | table host durationSeconds first start last stop 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any time that you can avoid transaction, you should; it is very slow/costly to use it.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 16:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206904#M40847</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-09-08T16:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206905#M40848</link>
      <description>&lt;P&gt;Sorry for replying late.. Below given is the data in which you can see that "Sending reply for message" and "reply message sent" both have sharing the same timestamp so after subtraction the both events timestamp duration will be 0 but I need these both events to come in output.&lt;/P&gt;

&lt;P&gt;DEBUG [main] 09-08 12:30:26 Sending reply for message &lt;A href="Sending.java:309"&gt;mail box: xyz@basware.com, sender: abc@basware.com, subject: Email Fetcher Performance Testing &amp;lt;&amp;lt;&amp;lt; current timestamp: 1441715338532 &amp;gt;&amp;gt;&amp;gt;&lt;/A&gt;&lt;BR /&gt;
DEBUG [main] 09-08 12:30:26 validating velocity Template path... (Sending.java:508) &lt;BR /&gt;
DEBUG [main] 09-08 12:30:26 reply message sent. (Sending.java:392) &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 05:36:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206905#M40848</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-09T05:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206906#M40849</link>
      <description>&lt;P&gt;Sorry for replying late. If  i am running your first query it is giving me the result given below &lt;/P&gt;

&lt;P&gt;9/8/15 8:05:19.000 PM DEBUG [main] 09-08 14:35:19 whiteList.getEmailAccount().toLowerCase(): &lt;A href="mailto:abc@bscs.basware.com"&gt;abc@bscs.basware.com&lt;/A&gt;  (MailFetcherDatabaseProcessor.java:118) &lt;BR /&gt;
9/8/15 8:05:19.000 PM DEBUG [main] 09-08 14:35:19 Successfully loaded MailFetcher 'WhiteList' from database  (MailFetcherDatabaseProcessor.java:120) &lt;/P&gt;

&lt;P&gt;but didn't get that where is the Session ID generating in the above given output and if i am running your second query by combining with the first one, i am getting the below output&lt;/P&gt;

&lt;P&gt;host    start   stop    durationSeconds&lt;BR /&gt;
hostname    1434603838  1434603844  6&lt;/P&gt;

&lt;P&gt;It is not the exact the output what i am want. I want the duration in seconds after subtracting the two events i.e. "Sending reply for message" and "reply message sent"  where as in your query you have mentioned only one event that is "Sending reply for message". Please advise.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 06:44:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206906#M40849</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-09T06:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206907#M40850</link>
      <description>&lt;P&gt;Below given is the sample data in which you can see that "Sending reply for message" and "reply message sent" both have sharing the same timestamp so after subtraction the both events timestamp duration will be 0 but I need these both events to come in output.&lt;/P&gt;

&lt;P&gt;DEBUG [main] 09-08 12:30:26 Sending reply for message &lt;A href="Sending.java:309"&gt;mail box: xyz@basware.com, sender: abc@basware.com, subject: Email Fetcher Performance Testing &amp;lt;&amp;lt;&amp;lt; current timestamp: 1441715338532 &amp;gt;&amp;gt;&amp;gt;&lt;/A&gt;&lt;BR /&gt;
DEBUG [main] 09-08 12:30:26 validating velocity Template path... (Sending.java:508)&lt;BR /&gt;
DEBUG [main] 09-08 12:30:26 reply message sent. (Sending.java:392) &lt;/P&gt;

&lt;P&gt;My query is something like this &lt;/P&gt;

&lt;P&gt;index="abc" sourcetype="xyz" | transaction startswith="Sending reply for message" endswith="reply message sent" | table host duration _time&lt;/P&gt;

&lt;P&gt;and the output is given below but as you see I want to include both the events in output that is not coming currently so could you please suggest something for this. thanks&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host         duration        _time
 sc-pet-cif      0      2015-08-31 21:50:37
 sc-pet-cif      0      2015-08-31 21:48:30 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2015 07:45:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206907#M40850</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-09T07:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206908#M40851</link>
      <description>&lt;P&gt;If you want to see the transaction time (which actually is 0 in your example, you can output the raw results with the command &lt;BR /&gt;
&lt;CODE&gt;... | table _raw, duration&lt;/CODE&gt;&lt;BR /&gt;
This will give you both events and the transaction duration.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 08:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206908#M40851</guid>
      <dc:creator>DennisMohn</dc:creator>
      <dc:date>2015-09-09T08:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206909#M40852</link>
      <description>&lt;P&gt;Thanks a lot Dennis... It works..&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 10:20:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206909#M40852</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-09T10:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206910#M40853</link>
      <description>&lt;P&gt;Glad I could help you!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 13:56:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206910#M40853</guid>
      <dc:creator>DennisMohn</dc:creator>
      <dc:date>2015-09-09T13:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206911#M40854</link>
      <description>&lt;P&gt;Based on your new clarification, I have revised my answer (again).  I think it will give you what you are trying to get.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2015 17:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206911#M40854</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-09-09T17:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration in seconds between two events?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206912#M40855</link>
      <description>&lt;P&gt;thanks for replying but still not getting the exact result but anyhow I got the answer by Dennis and it is fulfilled my requirement. Regards&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 07:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-calculate-duration-in-seconds-between-two-events/m-p/206912#M40855</guid>
      <dc:creator>sunnyparmar</dc:creator>
      <dc:date>2015-09-10T07:49:28Z</dc:date>
    </item>
  </channel>
</rss>

