<?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: Duration between Logoff and Logon in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376582#M110565</link>
    <description>&lt;P&gt;@vishaltv If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2019 12:39:31 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2019-05-22T12:39:31Z</dc:date>
    <item>
      <title>Duration between Logoff and Logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376579#M110562</link>
      <description>&lt;P&gt;Hi team,&lt;/P&gt;

&lt;P&gt;Please help me to figure out the issue.&lt;BR /&gt;
I would like to create a dashboard using my Audit logs to capture my break time.&lt;BR /&gt;
I'm trying to use time difference between Successful Logoff and Logon, That duration would be my breaktime.&lt;BR /&gt;
I wrote a SPL, but no results obtained. &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Event 1&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;05/16/2019 03:00:05 PM&lt;BR /&gt;
LogName=Security&lt;BR /&gt;
SourceName=Microsoft Windows security auditing.&lt;BR /&gt;
EventCode=4624&lt;BR /&gt;
EventType=0&lt;BR /&gt;
Type=Information&lt;BR /&gt;
ComputerName=IN2119801W3.ey.net&lt;BR /&gt;
TaskCategory=Logon&lt;BR /&gt;
OpCode=Info&lt;BR /&gt;
RecordNumber=240116&lt;BR /&gt;
Keywords=Audit Success&lt;BR /&gt;
Message=An account was successfully logged on.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Event 2&lt;/EM&gt;&lt;BR /&gt;
&lt;STRONG&gt;05/16/2019 02:30:00 PM&lt;BR /&gt;
LogName=Security&lt;BR /&gt;
SourceName=Microsoft Windows security auditing.&lt;BR /&gt;
EventCode=4634&lt;BR /&gt;
EventType=0&lt;BR /&gt;
Type=Information&lt;BR /&gt;
ComputerName=IN2119801W3.ey.net&lt;BR /&gt;
TaskCategory=Logoff&lt;BR /&gt;
OpCode=Info&lt;BR /&gt;
RecordNumber=238613&lt;BR /&gt;
Keywords=Audit Success&lt;BR /&gt;
Message=An account was logged off.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Splunk query&lt;/EM&gt; &lt;BR /&gt;
&lt;STRONG&gt;index="mymachinelogs" Keywords="Audit Success"  TaskCategory=Logoff OR TaskCategory=Logon | transaction TaskCategory startswith="Logoff" endswith="Logon" maxevents=2 | table _time TaskCategory duration&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;No results found&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:12:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376579#M110562</guid>
      <dc:creator>vishaltv</dc:creator>
      <dc:date>2019-05-16T15:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Duration between Logoff and Logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376580#M110563</link>
      <description>&lt;P&gt;You are using TaskCategory as the field to compare for your transaction.  This means you will never get Logon and Logoff in the same transaction.  You would need to use a field that will have the same value for both the Logon and the Logoff events.  You can do your startswith and endswith like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;startswith=(TaskCategory=Logoff) endswith=(TaskCategory=Logon)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 May 2019 16:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376580#M110563</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2019-05-16T16:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Duration between Logoff and Logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376581#M110564</link>
      <description>&lt;P&gt;Hi Guys, &lt;BR /&gt;
I've figured out the issue and fixed it. Now I'm getting the Break Time logs &lt;/P&gt;

&lt;P&gt;Step 1 : Import the realtime data from our Event Viewer log of our Machine - wineventlog:security&lt;/P&gt;

&lt;P&gt;Settings &amp;gt; Data Inputs&amp;gt; Local event log collection - Add security&lt;/P&gt;

&lt;P&gt;Search Query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=" * " sourcetype="wineventlog:security" Keywords="Audit Success" (EventCode="4800" OR EventCode="4801") | transaction startswith=(EventCode="4800") endswith=(EventCode="4801") maxspan=*  | eval _timezone = "IST"  | eval
_time_IST = _time - (strptime("2000-01-01 +00:00", "%F %:z") - strptime("2000-01-01 " . strftime(_time, "%:z"), "%F %Z")) + (strptime("2000-01-01 +00:00", "%F %:z") - strptime("2000-01-01 " .
_timezone, "%F %Z"))  | eval time_in_IST = strftime(_time_IST, "%F %T " . _timezone)  | rename time_in_IST as Time | eval Duration=strftime(duration,"%H:%M:%S") | table Time Durat* | sort - Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Event Code 4800 &amp;amp; 4801 - are Eventcode for Workstation Logout and Login&lt;BR /&gt;
Took transaction time between Workstation Logoff to Login as Duration&lt;BR /&gt;
Converted Time Zone to IST (Optional)&lt;BR /&gt;
Made Table using Duration vs TimeStamp (IST)&lt;/P&gt;

&lt;P&gt;Result :&lt;BR /&gt;
Time Duration&lt;BR /&gt;
2019-05-22 12:44:31 IST 00:27:53&lt;BR /&gt;
2019-05-22 12:37:01 IST 00:06:09&lt;BR /&gt;
2019-05-22 11:50:26 IST 00:01:03&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7072i9514BCE11BDCA5F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 08:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376581#M110564</guid>
      <dc:creator>vishaltv</dc:creator>
      <dc:date>2019-05-22T08:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Duration between Logoff and Logon</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376582#M110565</link>
      <description>&lt;P&gt;@vishaltv If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 12:39:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Duration-between-Logoff-and-Logon/m-p/376582#M110565</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-05-22T12:39:31Z</dc:date>
    </item>
  </channel>
</rss>

