<?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 subtract times for different events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192064#M187216</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i have multiple events for each order and i want to subtract start and end events for each order.  So i have created a filed called "action" and which gives whether it is a start or end event. So the value for "action" field would be start or end. i have converted time to numeral number but i am not sure how to get times for start and end and then subtract for each order to calculate the latency. i have used the query below. but not sure how to move forward.  Any suggestions please. &lt;/P&gt;

&lt;P&gt;| convert mktime(_time) as T1 | eval Type=if(action=start,"start","end") | stats values(T1) as Time by Type, Order | eval Latency = ("Time: start" - "Time: end") | &lt;/P&gt;</description>
    <pubDate>Fri, 22 Aug 2014 16:17:31 GMT</pubDate>
    <dc:creator>xvxt006</dc:creator>
    <dc:date>2014-08-22T16:17:31Z</dc:date>
    <item>
      <title>How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192064#M187216</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i have multiple events for each order and i want to subtract start and end events for each order.  So i have created a filed called "action" and which gives whether it is a start or end event. So the value for "action" field would be start or end. i have converted time to numeral number but i am not sure how to get times for start and end and then subtract for each order to calculate the latency. i have used the query below. but not sure how to move forward.  Any suggestions please. &lt;/P&gt;

&lt;P&gt;| convert mktime(_time) as T1 | eval Type=if(action=start,"start","end") | stats values(T1) as Time by Type, Order | eval Latency = ("Time: start" - "Time: end") | &lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 16:17:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192064#M187216</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-08-22T16:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192065#M187217</link>
      <description>&lt;P&gt;_time is already in epoch format right? why do you need to convert?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 17:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192065#M187217</guid>
      <dc:creator>strive</dc:creator>
      <dc:date>2014-08-22T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192066#M187218</link>
      <description>&lt;P&gt;Since start occurs first and end in the last, can you try this simple approach...&lt;BR /&gt;
Your search... | stats max(_time) as End, min(_time) as Start by OMSOrder | eval Latency = End - Start&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192066#M187218</guid>
      <dc:creator>strive</dc:creator>
      <dc:date>2020-09-28T17:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192067#M187219</link>
      <description>&lt;P&gt;Try this (assuming the value of the field Type is either 'start' or 'end')&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | chart first(_time) over action by OMSOrder | eval latency=end-start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Aug 2014 17:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192067#M187219</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-22T17:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192068#M187220</link>
      <description>&lt;P&gt;Awesome..Simple is better&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 20:01:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192068#M187220</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-08-22T20:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192069#M187221</link>
      <description>&lt;P&gt;One question is, i get the latency and when i use strftime i am getting the actual time but not the duration in secs or millli seconds. is there any function for that&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 20:29:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192069#M187221</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-08-22T20:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192070#M187222</link>
      <description>&lt;P&gt;The latency calculated here will be seconds already (as end and start are epoch time). You want to format the latency value to any specify format? If you want to format it as duration, your can use this in the search.&lt;/P&gt;

&lt;P&gt;after chart command | eval latency=tostring(end-start,"duration")&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 20:37:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192070#M187222</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-22T20:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract times for different events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192071#M187223</link>
      <description>&lt;P&gt;i got it. i have used | convert dur2sec(Latency)&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 20:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-times-for-different-events/m-p/192071#M187223</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-08-22T20:42:44Z</dc:date>
    </item>
  </channel>
</rss>

