<?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: Calculate time difference between two events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578682#M201680</link>
    <description>&lt;P&gt;I don't understand the logic of this query.&amp;nbsp; If either a 6005 or a 6006 is received then it is considered a "startup" and if any other event is received from the same host then it is a "shutdown".&amp;nbsp; Should one event code indicate a startup and the other a shutdown?&lt;/P&gt;&lt;P&gt;Perhaps this query will help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="wineventlog" host IN (xxxx) EventCode=6006 OR EventCode="6005" Type=Information
| stats earliest(_time) as Shutdown, latest(_time) as Startup by host
| eval Downtime=tostring(Startup-Shutdown, "duration")
| table host Shutdown Startup Downtime
| fieldformat Shutdown=strftime(Shutdown,"%c")
| fieldformat Startup=strftime(Startup,"%c")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Dec 2021 22:30:59 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-12-16T22:30:59Z</dc:date>
    <item>
      <title>Calculate time difference between two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578640#M201665</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the below search to calculate time difference between two events ie., 6006 and 6005&lt;BR /&gt;&lt;BR /&gt;6006 is event start time and 6006 is event stopped time. If we find the difference we will get to know the downtime of the system.&lt;/P&gt;&lt;P&gt;This is what i have tried. To few systems it is right and for few it is wrong.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index="wineventlog" host IN (xxxx) EventCode=6006 OR EventCode="6005" Type=Information&lt;BR /&gt;| stats latest(_time) as StartUp by host&lt;BR /&gt;| join host&lt;BR /&gt;[ search index="wineventlog" host IN (xxxx)&lt;BR /&gt;| stats latest(_time) as Shutdown by host ]&lt;BR /&gt;| eval difference=StartUp-Shutdown&lt;BR /&gt;| eval humanTime = strftime(difference*86400)&lt;BR /&gt;| table host humanTime&lt;BR /&gt;&lt;BR /&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 14:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578640#M201665</guid>
      <dc:creator>priya1926</dc:creator>
      <dc:date>2021-12-16T14:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578682#M201680</link>
      <description>&lt;P&gt;I don't understand the logic of this query.&amp;nbsp; If either a 6005 or a 6006 is received then it is considered a "startup" and if any other event is received from the same host then it is a "shutdown".&amp;nbsp; Should one event code indicate a startup and the other a shutdown?&lt;/P&gt;&lt;P&gt;Perhaps this query will help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="wineventlog" host IN (xxxx) EventCode=6006 OR EventCode="6005" Type=Information
| stats earliest(_time) as Shutdown, latest(_time) as Startup by host
| eval Downtime=tostring(Startup-Shutdown, "duration")
| table host Shutdown Startup Downtime
| fieldformat Shutdown=strftime(Shutdown,"%c")
| fieldformat Startup=strftime(Startup,"%c")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 22:30:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578682#M201680</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-12-16T22:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between two events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578700#M201682</link>
      <description>&lt;P&gt;Thanks that helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 05:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-two-events/m-p/578700#M201682</guid>
      <dc:creator>priya1926</dc:creator>
      <dc:date>2021-12-17T05:10:47Z</dc:date>
    </item>
  </channel>
</rss>

