<?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 calculate the time difference between two events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220802#M64877</link>
    <description>&lt;P&gt;Lets try a different approach&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dynatrace "failed events" transactioname=* |  stats earliest(_time) as start latest(_time) as end by host transactionname | eval duration=tostring(round(end-start, 0), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Aug 2016 18:38:35 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-08-12T18:38:35Z</dc:date>
    <item>
      <title>How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220792#M64867</link>
      <description>&lt;P&gt;Hello Splunk'all,&lt;/P&gt;

&lt;P&gt;I am trying to derive a simple chart from the data I got here within a Splunk Index. The data consists of epoch time (field name is "&lt;STRONG&gt;transactiontime&lt;/STRONG&gt;") and the transaction values. The transactions contains success and failures and every transaction has an epoch timestamp for the transaction occurred.&lt;BR /&gt;
I am simply trying to create a graph with the data for the time between every failure. For example: in a day, if there are two failures, one at 3 AM and one at 8 PM, I am trying to create a graph and show the time between these two failures (which is 17 Hrs). SO I took some help from a colleague of mine and got to this stage (please see below) and I am able to take two transactions into one field, but the time difference between those epoch values of two transactions are showing wrong. &lt;BR /&gt;
Please see the search below and let me know for any missing logic I need to incorporate here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="dynatrace" transactionname="*"
sort _time| 
search tpf &amp;gt; 0 |
eval cvtime=strftime(transactiontime/1000, "%H:%M:%S %d-%m-%Y") |
transaction host maxevents=2 |
eval mdiff=round(duration)|
table mdiff,cvtime,ttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks &lt;BR /&gt;
Vikram Y&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 21:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220792#M64867</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-09T21:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220793#M64868</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;UPDATED&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=dynatrace "failed events" transactioname=* |  stats earliest(_time) as start latest(_time) as end by host transactionname | eval duration=tostring(round(end-start, 0), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Aug 2016 22:23:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220793#M64868</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-09T22:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220794#M64869</link>
      <description>&lt;P&gt;Hi  sundar,&lt;BR /&gt;
I do see your logic here. You took the "_time" and calculated the output based on the parameter we need ("&lt;STRONG&gt;failed events&lt;/STRONG&gt;"in this case). I am getting the full list individually now in the output. Thats really good..&lt;BR /&gt;
I am actually trying to achieve to get the time difference between two individual events and put them into the Visualization in Splunk.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Vikram Y&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 15:14:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220794#M64869</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-10T15:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220795#M64870</link>
      <description>&lt;P&gt;Actually I forgot to notice this before:&lt;BR /&gt;
&lt;CODE&gt;eval delta=tostring(_time-prevtime, "duration")&lt;/CODE&gt; is not outputting any value.. Looking more into it.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Vikram Yerneni&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 15:17:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220795#M64870</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-10T15:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220796#M64871</link>
      <description>&lt;P&gt;Try this runanywhere sample&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | streamstats window=1 current=f earliest(_time) as nextTime by host sourcetype | eval duration=nextTime-_time | table _time nextTime duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Aug 2016 17:31:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220796#M64871</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-10T17:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220797#M64872</link>
      <description>&lt;P&gt;Hey Sundar, I was off for last two days. Let me validate it and will get back to you.&lt;BR /&gt;
Thanks man..&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 14:40:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220797#M64872</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T14:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220798#M64873</link>
      <description>&lt;P&gt;Hi Sundar,&lt;/P&gt;

&lt;P&gt;Yes the "runanywhere sample" worked with output (Duration as "0"). However the earlier query you provided actually is not providing output to &lt;CODE&gt;eval delta=tostring(_time-prevtime, "duration") |&lt;/CODE&gt;. I do see the logic here taking the previous provided time and subtracting it from _time (current time) which will give the time in between these two events. &lt;BR /&gt;
Not sure why I did multiple combinations but still its not outputting it.&lt;/P&gt;

&lt;P&gt;Any thoughts here..?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Vikram Y&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 15:31:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220798#M64873</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T15:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220799#M64874</link>
      <description>&lt;P&gt;Try the updated search..&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 17:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220799#M64874</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-12T17:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220800#M64875</link>
      <description>&lt;P&gt;Same response Sundar. Still its showing "Delta" field with blank values. I cant upload a screenshot to this ticket yet as I dont have enough Karma points..&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Vikram Y&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:07:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220800#M64875</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T18:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220801#M64876</link>
      <description>&lt;P&gt;What do you get when you run this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dynatrace "failed events" | reverse | streamstats window=1 current=f earliest(_time) as prevTime by host transactionname | table host transactionname  _time prevTIme
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:16:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220801#M64876</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-12T18:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220802#M64877</link>
      <description>&lt;P&gt;Lets try a different approach&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=dynatrace "failed events" transactioname=* |  stats earliest(_time) as start latest(_time) as end by host transactionname | eval duration=tostring(round(end-start, 0), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220802#M64877</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-12T18:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220803#M64878</link>
      <description>&lt;P&gt;Now it worked.. "Reverse" made  differnece.. Plus one thing I noticed is the query is Case-sensitive.. Atleast now I am getting right data into the Statistics page.. &lt;BR /&gt;
Let me validate the data and will get back to you soon Sundar..&lt;BR /&gt;
Thanks man..&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220803#M64878</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T18:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220804#M64879</link>
      <description>&lt;P&gt;Awesome. Once validated, please accept/upvote the answer&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:54:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220804#M64879</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-12T18:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220805#M64880</link>
      <description>&lt;P&gt;Absolutely sir.. will do..&lt;BR /&gt;
Thanks again dude..&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220805#M64880</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T19:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220806#M64881</link>
      <description>&lt;P&gt;Alright the data looks good.&lt;BR /&gt;
One last point I noticed here is the logic provided here will take the first _time and subtracts from the next one and because of that the first column in the result the "delta" output is blank which dosen't make the visualization graphs a blank. &lt;BR /&gt;
Is there a way to remove this first line from the output or fill it with "0" for any blank values? &lt;BR /&gt;
Let me know sir..&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Vikram Yerneni&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:21:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220806#M64881</guid>
      <dc:creator>vikramyerneni</dc:creator>
      <dc:date>2016-08-12T19:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to calculate the time difference between two events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220807#M64882</link>
      <description>&lt;P&gt;@vikramyerneni, just add &lt;CODE&gt;fillnull value=0 delta&lt;/CODE&gt; that will fill null values with 0, in your case, the first row&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:23:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-calculate-the-time-difference-between/m-p/220807#M64882</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-12T19:23:16Z</dc:date>
    </item>
  </channel>
</rss>

