<?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 create Screen Lock Time of Windows PC calculation into timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/585249#M203880</link>
    <description>&lt;P&gt;Please accept the solution if the answer was helpful to you.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 04:31:07 GMT</pubDate>
    <dc:creator>VatsalJagani</dc:creator>
    <dc:date>2022-02-16T04:31:07Z</dc:date>
    <item>
      <title>How to create sleep time of Windows PC calculation into timechart?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584528#M203635</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I am using following search into Windows EventViewer System logs&amp;nbsp; that I extracted for testing:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;index="503461" host="hp-laptop" "Sleep Time"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Log looks like below:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="195px"&gt;
&lt;P&gt;Information,4.2.2022 г. 12:55:47,Microsoft-Windows-Power-Troubleshooter,1,None,"The system has returned from a low power state.&lt;/P&gt;
&lt;P&gt;Sleep Time: ‎2022‎-‎02‎-‎04T10:38:18.391571900Z&lt;BR /&gt;Wake Time: ‎2022‎-‎02‎-‎04T10:55:46.701556600Z&lt;/P&gt;
&lt;P&gt;Wake Source: Device -USB Composite Device"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to calculate the two time stamps into total duration. Can someone help with the search string, thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 04:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584528#M203635</guid>
      <dc:creator>skovachev</dc:creator>
      <dc:date>2022-02-16T04:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Sleep Time of Windows PC calculation into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584673#M203676</link>
      <description>&lt;P&gt;Easy:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="503461" host="hp-laptop" "Sleep Time"
| rex field=Sleep_Time max_match=0 "(?&amp;lt;test&amp;gt;[\w:\.\-]+)" | eval Sleep_Time = mvjoin(test, "")
| rex field=Wake_Time max_match=0 "(?&amp;lt;test2&amp;gt;[\w:\.\-]+)" | eval Wake_Time = mvjoin(test2, "")
| eval Sleep_Time2=strptime(Sleep_Time, "%FT%T.%9QZ")
| eval Wake_Time2=strptime(Wake_Time, "%FT%T.%9QZ")
| eval Duration=Wake_Time2-Sleep_Time2&lt;/LI-CODE&gt;&lt;P&gt;* line-2 and line-3 are to remove special characters from the _raw time as what I saw in case.&lt;/P&gt;&lt;P&gt;* line-3 and line-4 convert the string time format to an epoch number.&lt;/P&gt;&lt;P&gt;* line-5 calculate the duration in seconds (floating point number)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 08:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584673#M203676</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-02-11T08:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Screen Lock Time of Windows PC calculation into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584977#M203788</link>
      <description>&lt;P&gt;HI Vatsa,&lt;/P&gt;&lt;P&gt;Thank you for the time you spent with my problem. I am unable to figure out the regex.&lt;/P&gt;&lt;P&gt;I am trying another scenario now where I calculate the Scree Locked time minus the screen Unlock time so I can get total duration of screen was locked on a windows pc. Here are the logs and what I managed to put together so far.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;SPAN class=""&gt;Information&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Audit&lt;/SPAN&gt; &lt;SPAN class=""&gt;Success&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;11.2.2022&lt;/SPAN&gt; &lt;SPAN class=""&gt;г&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt; &lt;SPAN class=""&gt;13:51:11&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Microsoft-Windows-Security-Auditing&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;4800&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Other&lt;/SPAN&gt; &lt;SPAN class=""&gt;Logon/Logoff&lt;/SPAN&gt; &lt;SPAN class=""&gt;Events&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Security&lt;/SPAN&gt;&lt;SPAN&gt;,"&lt;/SPAN&gt;&lt;SPAN class=""&gt;The&lt;/SPAN&gt; &lt;SPAN class=""&gt;workstation&lt;/SPAN&gt; &lt;SPAN class=""&gt;was&lt;/SPAN&gt; &lt;SPAN class=""&gt;locked.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100.12626262626263%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;SPAN class=""&gt;Information&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Audit&lt;/SPAN&gt; &lt;SPAN class=""&gt;Success&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;11.2.2022&lt;/SPAN&gt; &lt;SPAN class=""&gt;г&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt; &lt;SPAN class=""&gt;13:51:19&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Microsoft-Windows-Security-Auditing&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;4801&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Other&lt;/SPAN&gt; &lt;SPAN class=""&gt;Logon/Logoff&lt;/SPAN&gt; &lt;SPAN class=""&gt;Events&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;Security&lt;/SPAN&gt;&lt;SPAN&gt;,"&lt;/SPAN&gt;&lt;SPAN class=""&gt;The&lt;/SPAN&gt; &lt;SPAN class=""&gt;workstation&lt;/SPAN&gt; &lt;SPAN class=""&gt;was&lt;/SPAN&gt; &lt;SPAN class=""&gt;unlocked.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index="........."&lt;BR /&gt;| rename EXTRA_FIELD_8 as message&lt;BR /&gt;| rename "Event ID" as eventid&lt;BR /&gt;| rename "Date and Time" as DT&lt;BR /&gt;| eval message=if((eventid=4800),"LOCKED", "UNLOCKED")&lt;BR /&gt;| table message,DT&lt;/P&gt;&lt;P&gt;I would appreciate any help with substracting Locked time from Unlock time and creating a Mon-Fri timechart that shows duration of a pc on screenlock &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 12:27:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584977#M203788</guid>
      <dc:creator>skovachev</dc:creator>
      <dc:date>2022-02-14T12:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Screen Lock Time of Windows PC calculation into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584992#M203789</link>
      <description>&lt;P&gt;This is totally different scenario because in the original case you had both the information in a single event but here you have two events for two activities.&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="........."
| eval message=if((eventid=4800),"LOCKED", "UNLOCKED")
| transaction maxevents=2 host startswith="message=LOCKED" endswith="message=UNLOCKED"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See you should have a &lt;STRONG&gt;duration&lt;/STRONG&gt; field in the results now. If you are getting all negative values, interchange &lt;STRONG&gt;startswith&lt;/STRONG&gt; with &lt;STRONG&gt;endswith&lt;/STRONG&gt; in the transaction command. Or you can also take &lt;STRONG&gt;abs(duration)&lt;/STRONG&gt; with eval, which will also convert negative values to positive values. Or you can also multiply by -1.&lt;/P&gt;&lt;P&gt;Once you have it you can do timechart or stats whatever you want to apply after that.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 14:18:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/584992#M203789</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-02-14T14:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Screen Lock Time of Windows PC calculation into timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/585249#M203880</link>
      <description>&lt;P&gt;Please accept the solution if the answer was helpful to you.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 04:31:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-sleep-time-of-Windows-PC-calculation-into/m-p/585249#M203880</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-02-16T04:31:07Z</dc:date>
    </item>
  </channel>
</rss>

