<?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 use transaction command to show Windows time difference between two EventCodes? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320667#M59841</link>
    <description>&lt;P&gt;Thanks. I'm glad to help! I enjoy SPL challenges.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2017 12:52:43 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2017-10-26T12:52:43Z</dc:date>
    <item>
      <title>How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320656#M59830</link>
      <description>&lt;P&gt;I want to capture EventCode=1100 , but I also want to know if EventCode=4608 is created in one minute after EventCode=1100,  If EventCode is created by itself and is not followed by EventCode=4608, I want to know that.  Here's the search syntax I have, but the results are not what I really want.  I don't know if what I have captures the gist of what I'm trying to do.&lt;/P&gt;

&lt;P&gt;[10:19] &lt;BR /&gt;
index=wineventlog source="WinEventLog:Security" host=* ((EventCode=1100 body="The event logging service has shut down.") OR (EventCode=4608 ) ) &lt;BR /&gt;
| transaction EventCode maxspan=1m&lt;BR /&gt;
| table _time, EventCode, host,body&lt;BR /&gt;
| sort -_time&lt;/P&gt;

&lt;P&gt;[10:20] &lt;BR /&gt;
The results are something like this:&lt;/P&gt;

&lt;P&gt;[10:20] &lt;BR /&gt;
2017-10-16 01:03:29    4608    Windows is starting up. &lt;BR /&gt;
2017-10-15 23:01:51    4608    Windows is starting up. &lt;BR /&gt;
2017-10-15 23:01:21    1100    The event logging service has shut down.&lt;BR /&gt;
2017-10-15 20:02:59    4608    Windows is starting up. &lt;BR /&gt;
2017-10-15 01:15:31    4608    Windows is starting up.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:22:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320656#M59830</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2020-09-29T16:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320657#M59831</link>
      <description>&lt;P&gt;Right now, you are telling &lt;CODE&gt;transaction&lt;/CODE&gt; to consider a group of events a single transaction if they share the same EventCode, but I think you want to consider two events part of the same transaction if they are marked by a starting &lt;CODE&gt;EventCode=1100&lt;/CODE&gt; and an ending &lt;CODE&gt;EventCode=4608&lt;/CODE&gt;. In that case, you'll want to use the arguments &lt;CODE&gt;startswith&lt;/CODE&gt; and &lt;CODE&gt;endswith&lt;/CODE&gt;, as documented:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Transaction"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So I think you'll want something like this:&lt;BR /&gt;
&lt;CODE&gt;index=wineventlog source="WinEventLog:Security" host=* ((EventCode=1100 body="The event logging service has shut down.") OR (EventCode=4608 ) ) | transaction maxspan=1m startswith=eval(EventCode=1100) endswith=eval(EventCode=4608) keeporphans=true | where _txn_orphan=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Splunk will consider starting events (EventCode=1100) that don't have a corresponding ending event (EventCode=4608) within the maxspan window to be orphans. Hence the need to include &lt;CODE&gt;keeporphans=true&lt;/CODE&gt; and then finally filter to display only the orphans.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 21:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320657#M59831</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-20T21:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320658#M59832</link>
      <description>&lt;P&gt;@elliotproebstel - Good start.  Your answer is an improvement for the OP, but there is more improvement there to be had.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Transaction&lt;/CODE&gt; is a real resource hog, so here's a challenge for you: see if you can refactor this query to meet the need using a &lt;CODE&gt;streamstats&lt;/CODE&gt; command instead of &lt;CODE&gt;transaction&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Come up with good code for that, tag me on the reply here and I'll upvote it.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 02:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320658#M59832</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-23T02:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320659#M59833</link>
      <description>&lt;P&gt;Thanks for the challenge @DalJeanis! You're right; although the OP specifically requested guidance on how to use the &lt;CODE&gt;transaction&lt;/CODE&gt; command to complete this task, I should have at least mentioned that &lt;CODE&gt;transaction&lt;/CODE&gt; is resource-intensive and rarely the most efficient way to solve a problem.&lt;/P&gt;

&lt;P&gt;I'm pretty sure this should achieve the same goal:&lt;BR /&gt;
&lt;CODE&gt;index=wineventlog source="WinEventLog:Security" (1100 EventCode=1100) OR (4608 EventCode=4608) | streamstats count reset_after=(EventCode=1100) time_window=1m | search EventCode=1100 count=1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;In this approach, the &lt;CODE&gt;streamstats&lt;/CODE&gt; command will walk through events in the order returned from the original search (which, by default, is reverse-chronological) and apply a field called &lt;CODE&gt;count&lt;/CODE&gt;. The value of &lt;CODE&gt;count&lt;/CODE&gt; will reset every time either of these two conditions is met:&lt;BR /&gt;
1. The time between two events is greater than the specified &lt;CODE&gt;time_window&lt;/CODE&gt; value of 1 minute; OR&lt;BR /&gt;
2. The search encounters an event where &lt;CODE&gt;EventCode=1100&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;In the case of #1, the count will reset before it is applied to the next event. In the case of #2, the count will reset after it is applied to the event with &lt;CODE&gt;EventCode=1100&lt;/CODE&gt;. Thus, every event with &lt;CODE&gt;EventCode=1100&lt;/CODE&gt; where &lt;CODE&gt;count&amp;gt;1&lt;/CODE&gt; is guaranteed to be followed by an event with &lt;CODE&gt;EventCode=4608&lt;/CODE&gt; within 1 min.&lt;/P&gt;

&lt;P&gt;One thing that wasn't specified in the original post but is likely needed: OP, if your Windows logs are coming from multiple hosts, you might be wanting to narrow your search to look for events with &lt;CODE&gt;EventCode=1100&lt;/CODE&gt; followed by events with &lt;CODE&gt;EventCode=4608&lt;/CODE&gt; within the same minute &lt;STRONG&gt;from the same host&lt;/STRONG&gt;. If this is the case, you should add the clause &lt;CODE&gt;BY host&lt;/CODE&gt; like this:&lt;BR /&gt;
&lt;CODE&gt;index=wineventlog source="WinEventLog:Security" (1100 EventCode=1100) OR (4608 EventCode=4608) | streamstats count BY host reset_after=(EventCode=1100) time_window=1m | search EventCode=1100 count=1&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 14:06:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320659#M59833</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-23T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320660#M59834</link>
      <description>&lt;P&gt;If do the following search for the past four days and deliberately leave out "| where _txn_orphan=1" to see the total number of EventCode=1100, I get 5 results for EventCode=1100:&lt;/P&gt;

&lt;P&gt;index=wineventlog source="WinEventLog:Security" host=workstation1 ((EventCode=1100 body="The event logging service has shut down.") OR (EventCode=4608 ) ) &lt;BR /&gt;
| transaction startswith=eval(EventCode=1100) endswith=eval(EventCode=4608) maxspan=1m keeporphans=true &lt;BR /&gt;
| eval Time=strftime(_time, "%b %d %H:%M:%S") &lt;BR /&gt;
| table Time, EventCode, host,body,action &lt;BR /&gt;
| rename body to "Event Message", action to "Final Action", host to "Host Name", Time to "Time of Event"&lt;/P&gt;

&lt;P&gt;The following results of the above search show EventCode=1100 as an "orphan" five times:&lt;BR /&gt;
Time of Event&lt;BR /&gt;
EventCode&lt;BR /&gt;
Host Name&lt;BR /&gt;
Event Message&lt;BR /&gt;
Final Action&lt;/P&gt;

&lt;P&gt;Oct 22 23:02:07 1100&lt;BR /&gt;
4608    WORKSTATION1    The event logging service has shut down.&lt;BR /&gt;
Windows is starting up. This event is logged when LSASS.EXE starts and the auditing subsystem is initialized.   stopped&lt;BR /&gt;
success&lt;BR /&gt;
Oct 22 23:02:07 1100&lt;BR /&gt;
4608    WORKSTATION1    The event logging service has shut down.&lt;BR /&gt;
Windows is starting up. This event is logged when LSASS.EXE starts and the auditing subsystem is initialized.   stopped&lt;BR /&gt;
success&lt;BR /&gt;
Oct 22 23:02:07 1100    WORKSTATION1    The event logging service has shut down.    stopped&lt;BR /&gt;
Oct 22 23:02:07 1100    WORKSTATION1    The event logging service has shut down.    stopped&lt;BR /&gt;
Oct 22 23:02:07 1100    WORKSTATION1    The event logging service has shut down.    stopped&lt;BR /&gt;
Oct 22 01:14:47 1100&lt;BR /&gt;
4608    WORKSTATION1    The event logging service has shut down.&lt;BR /&gt;
Windows is starting up. This event is logged when LSASS.EXE starts and the auditing subsystem is initialized.   stopped&lt;BR /&gt;
success&lt;BR /&gt;
Oct 22 01:14:47 1100    WORKSTATION1    The event logging service has shut down.    stopped&lt;BR /&gt;
Oct 21 01:14:37 1100&lt;BR /&gt;
4608    WORKSTATION1    The event logging service has shut down.&lt;BR /&gt;
Windows is starting up. This event is logged when LSASS.EXE starts and the auditing subsystem is initialized.   stopped&lt;BR /&gt;
success&lt;BR /&gt;
Oct 21 01:14:37 1100    WORKSTATION1    The event logging service has shut down.    stopped&lt;/P&gt;

&lt;P&gt;And, if I do the streamstats version of the search below, I get 7 results for EventCode=1100.&lt;/P&gt;

&lt;P&gt;index=wineventlog source="WinEventLog:Security" host=workstation1 ((EventCode=1100 body="The event logging service has shut down.") OR (EventCode=4608 ) ) &lt;BR /&gt;
| streamstats count BY host reset_after=(EventCode=1100) time_window=1m &lt;BR /&gt;
| search EventCode=1100 count=1 &lt;BR /&gt;
| eval Time=strftime(_time, "%b %d %H:%M:%S") &lt;BR /&gt;
| table Time, EventCode, host,body,action &lt;BR /&gt;
| rename body to "Event Message", action to "Final Action", host to "Host Name", Time to "Time of Event"&lt;/P&gt;

&lt;P&gt;I'm doing the search for the same time.  Why are the results of the search different as far as the number of EventCode=1100 is concerned?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320660#M59834</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2020-09-29T16:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320661#M59835</link>
      <description>&lt;P&gt;To be clear, the original answer provided by @elliotproebstel does work. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 15:07:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320661#M59835</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2017-10-24T15:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320662#M59836</link>
      <description>&lt;P&gt;The interesting thing is that these "orphans" are taking place within the time frame of EventCode=1100 being followed by EventCode=4608.  Is there a way to search for "orphans" outside that time range only?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 16:15:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320662#M59836</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2017-10-24T16:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320663#M59837</link>
      <description>&lt;P&gt;Hmm...looking at the events you've posted here, I'm realizing that I made some assumptions about the data that aren't true at all. My code assumed there would be non-duplicative log entries marking the start and end of a "transaction". Seeing three events with &lt;CODE&gt;EventCode=1100&lt;/CODE&gt; in a row with the same timestamp violates that assumption. &lt;/P&gt;

&lt;P&gt;Not knowing exactly what your end purpose is with the data, I need to ask a couple clarifying questions. First, just to understand - is this entry an event with &lt;CODE&gt;EventCode=4608&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Oct 22 23:02:07 1100&lt;BR /&gt;
4608 WORKSTATION1 The event logging service has shut down.&lt;BR /&gt;
Windows is starting up. This event is logged when LSASS.EXE starts and the auditing subsystem is initialized. stopped&lt;BR /&gt;
success&lt;/CODE&gt; ??&lt;BR /&gt;
What is the &lt;CODE&gt;1100&lt;/CODE&gt; after the timestamp?  The rest of my answer will assume that this event is an event of type 4608.&lt;/P&gt;

&lt;P&gt;Given the entries that are all timestamped 23:02:07 - I see three &lt;CODE&gt;EventCode=1100&lt;/CODE&gt; events followed by two &lt;CODE&gt;EventCode=4608&lt;/CODE&gt; events. Do you want to consider all three &lt;CODE&gt;1100&lt;/CODE&gt; events effectively closed out by the &lt;CODE&gt;4608&lt;/CODE&gt; events, or are you looking to identify two of the &lt;CODE&gt;1100&lt;/CODE&gt; events as unmatched? &lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 16:40:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320663#M59837</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-24T16:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320664#M59838</link>
      <description>&lt;P&gt;The host reboots once a week and these EventCodes are generated as a consequence.  EventCode=1100 is generated when the event logging service has shut down.  This is anticipated since the workstation is shutting down.  Upon the system booting back up, EventCode=4608 is generated.  What I want to do is capture EventCode=1100 outside that reboot window.  For some reason the EventCode=1100 and EventCode=4608 are not one to one, but there seems to be more EventCode=1100 than EventCode=4608 produced during the reboot process.  EventCode=1100 happening outside that window would be suspicious as someone would have disabled event logging.  That's when I want to be able to catch it and make the alert an actionable alert.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 19:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320664#M59838</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2017-10-24T19:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320665#M59839</link>
      <description>&lt;P&gt;Got it. So you want to find any events with EventCode=1100 where there are no subsequent events with EventCode=4608 on the same host within 1 minute. But you don't need to worry about whether they are 1:1, so those three events with EventCode=1100 followed by two events with EventCode=4608 in the above data &lt;STRONG&gt;should not&lt;/STRONG&gt; generate an alert. In fact, if I'm understanding correctly, none of the events in the above data should generate an alert, correct?&lt;/P&gt;

&lt;P&gt;I'll have to think about it more carefully, but I think the streamstats approach should work if you replace &lt;CODE&gt;reset_after(EventCode=1100)&lt;/CODE&gt; with &lt;CODE&gt;reset_before(EventCode=4608)&lt;/CODE&gt;. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 20:50:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320665#M59839</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-24T20:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320666#M59840</link>
      <description>&lt;P&gt;That's correct.  Thank you for your help.  I made the change per your recommendation and I think I'm set.  You did a great job answering my questions and explaining in detail the correct search syntax.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320666#M59840</guid>
      <dc:creator>M2016G0216</dc:creator>
      <dc:date>2017-10-25T14:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use transaction command to show Windows time difference between two EventCodes?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320667#M59841</link>
      <description>&lt;P&gt;Thanks. I'm glad to help! I enjoy SPL challenges.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 12:52:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-use-transaction-command-to-show-Windows-time-difference/m-p/320667#M59841</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-26T12:52:43Z</dc:date>
    </item>
  </channel>
</rss>

