<?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 Calculate duration between Windows EventCodes in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96205#M20038</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new to Splunk, so if this is a stupid question - forgive me! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I want to calculate the duration between two Windows EventCodes to determine how long server restarts take across the organisation.&lt;/P&gt;

&lt;P&gt;The problem is that i don't have any unique field between the events to do the transaction on.&lt;/P&gt;

&lt;P&gt;These are the two events:&lt;/P&gt;

&lt;H1&gt;SERVER SHUTDOWN INITIATED&lt;/H1&gt;

&lt;P&gt;11/24/10 11:47:12 AM
LogName=System
SourceName=EventLog
EventCode=6006
EventType=4
Type=Information
ComputerName=XXXX
Category=0
CategoryString=none
RecordNumber=14339
Message=The Event log service was stopped.&lt;/P&gt;

&lt;H1&gt;SERVER RESTARTED AND ONLINE&lt;/H1&gt;

&lt;P&gt;11/24/10 11:49:38 AM
LogName=System
SourceName=EventLog
EventCode=6005
EventType=4
Type=Information
ComputerName=XXXX
Category=0
CategoryString=none
RecordNumber=14341
Message=The Event log service was started.&lt;/P&gt;

&lt;P&gt;I tried to do the transaction on the EventCode fields, this works to an extend but not 100% as it creates transaction across multiple servers. A workaround to this is to use the maxspan field. But sometimes the servers takes a long time to come online again making the use of maxspan difficult. I also tried using the RecordNumber field as the RecordNumber between normal shutdown and startups would be RecordNumber for shutdowns and RecordNumber+2 for startups.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2010 19:22:22 GMT</pubDate>
    <dc:creator>lohans</dc:creator>
    <dc:date>2010-11-30T19:22:22Z</dc:date>
    <item>
      <title>Calculate duration between Windows EventCodes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96205#M20038</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am new to Splunk, so if this is a stupid question - forgive me! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I want to calculate the duration between two Windows EventCodes to determine how long server restarts take across the organisation.&lt;/P&gt;

&lt;P&gt;The problem is that i don't have any unique field between the events to do the transaction on.&lt;/P&gt;

&lt;P&gt;These are the two events:&lt;/P&gt;

&lt;H1&gt;SERVER SHUTDOWN INITIATED&lt;/H1&gt;

&lt;P&gt;11/24/10 11:47:12 AM
LogName=System
SourceName=EventLog
EventCode=6006
EventType=4
Type=Information
ComputerName=XXXX
Category=0
CategoryString=none
RecordNumber=14339
Message=The Event log service was stopped.&lt;/P&gt;

&lt;H1&gt;SERVER RESTARTED AND ONLINE&lt;/H1&gt;

&lt;P&gt;11/24/10 11:49:38 AM
LogName=System
SourceName=EventLog
EventCode=6005
EventType=4
Type=Information
ComputerName=XXXX
Category=0
CategoryString=none
RecordNumber=14341
Message=The Event log service was started.&lt;/P&gt;

&lt;P&gt;I tried to do the transaction on the EventCode fields, this works to an extend but not 100% as it creates transaction across multiple servers. A workaround to this is to use the maxspan field. But sometimes the servers takes a long time to come online again making the use of maxspan difficult. I also tried using the RecordNumber field as the RecordNumber between normal shutdown and startups would be RecordNumber for shutdowns and RecordNumber+2 for startups.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 19:22:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96205#M20038</guid>
      <dc:creator>lohans</dc:creator>
      <dc:date>2010-11-30T19:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration between Windows EventCodes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96206#M20039</link>
      <description>&lt;P&gt;You can create a "transaction" on the host field and by specifying a starts-with and ends-with condition, you should get the desired results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=WinEventLog:System (EventCode=6005 OR EventCode=6006) 
| transaction host startswith="EventCode=6006" endswith="EventCode=6005" 
| eval restart_duration=tostring(duration,"duration") 
| table _time host restart_duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Nov 2010 19:51:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96206#M20039</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-11-30T19:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration between Windows EventCodes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96207#M20040</link>
      <description>&lt;P&gt;Thx a million! Exactly what i needed!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 21:05:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96207#M20040</guid>
      <dc:creator>lohans</dc:creator>
      <dc:date>2010-11-30T21:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration between Windows EventCodes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96208#M20041</link>
      <description>&lt;P&gt;Just one more question - why would the restart duration be displayed like this for some hosts? 378+14:52:21&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 21:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96208#M20041</guid>
      <dc:creator>lohans</dc:creator>
      <dc:date>2010-11-30T21:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration between Windows EventCodes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96209#M20042</link>
      <description>&lt;P&gt;Seems like 378 days... You can take a look at those found transactions by removing the eval and the table command and looking at long durations by appending | where duration&amp;gt;86400. It probably because of missing events or incorrectly parsed timestamps or something like that. Please accept the answer, if it was helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 21:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Calculate-duration-between-Windows-EventCodes/m-p/96209#M20042</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-11-30T21:36:52Z</dc:date>
    </item>
  </channel>
</rss>

