<?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: Secuirty checks with help of splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320967#M175416</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I think this query is not giving exact results. If we can see the csv file, for one employee there are multiple Time IN and multiple TIme OUT values are associated. We need to calculate total time spent in office for each employee.&lt;/P&gt;

&lt;P&gt;After i executed the above query it is giving duration values. Do we need to convert them into human readable if yes how?&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2017 10:38:33 GMT</pubDate>
    <dc:creator>srinivasup</dc:creator>
    <dc:date>2017-02-22T10:38:33Z</dc:date>
    <item>
      <title>Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320960#M175409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to figure out, how long an employee inside office. Once employee enters into office he will do card swipe that we can call it as IN time, and after sometime he can go for tea or coffice out side then he can do OUT. now we need to calculate the time inside office means difference between IN and out. After tea/coffee he can come in and do swipe IN, like that he can do many INs and OUTs in a day. We want to calculate total time he spent in office. Below sample shows the data. Can anyone answer plz &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;OfficeIn              Cardswipe 

 IN                     12:21:50
 OUT                    13:46:41
 IN                     14:31:19
 OUT                   17:54:24
 IN                     18:32:45
 OUT                   19:16:22
 IN                     19:25:27
 OUT                   21:46:49 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320960#M175409</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2017-02-21T12:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320961#M175410</link>
      <description>&lt;P&gt;A quick way would to use transaction.  Based on your data, it &lt;EM&gt;might&lt;/EM&gt; go something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;search_to_find_data&amp;gt; | transaction startswith="IN" endswith="OUT" max_span=12h | stats sum(duration) as Total_IN_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The transaction command will take your events and combine them on IN/OUT as a start/end point, respectively. The max span helps optimize the command by saying only look within a 12 hour window for an IN/OUT combination. Then, sum the durations of the IN/OUT transactions (time spent per IN/OUT) into a total time in Seconds. &lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320961#M175410</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2017-02-21T13:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320962#M175411</link>
      <description>&lt;P&gt;assuming you have a uniqie id for each user/card - cardId&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search|transaction cardId startswith=(OfficeIn="IN")  endswith=(OfficeIn="OUT") maxevents=2|stats sum(duration) as totalDuration by cardId
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320962#M175411</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-21T13:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320963#M175412</link>
      <description>&lt;P&gt;It is csv file and looks like exactly below&lt;/P&gt;

&lt;P&gt;Emp No  Name    Date    Status                 SwipeTime&lt;BR /&gt;
111           aaa   10/6/16 Time IN                 9:11:18&lt;BR /&gt;
111           aaa   10/6/16 Time OUT            9:50:25&lt;BR /&gt;
111           aaa   10/6/16 Time IN                 9:55:10&lt;BR /&gt;
111           aaa   10/6/16 Time OUT            12:38:28&lt;BR /&gt;
111           aaa   10/6/16 Time IN                 12:41:18&lt;BR /&gt;
222           bbb   10/6/16 Time OUT            13:05:05&lt;BR /&gt;
222           bbb   10/6/16 Time IN                 14:06:00&lt;BR /&gt;
222           bbb   10/6/16 Time OUT             15:50:31&lt;BR /&gt;
222           bbb   10/6/16 Time IN                  15:53:03&lt;BR /&gt;
222           bbb   10/6/16 Time OUT             17:58:47&lt;BR /&gt;
333            ccc  10/6/16 Time IN                  18:01:05&lt;BR /&gt;
333            ccc  10/6/16 Time OUT             18:39:43&lt;BR /&gt;
333            ccc  10/6/16 Time IN                   18:43:32&lt;BR /&gt;
333            ccc  10/6/16 Time OUT               19:04:01&lt;/P&gt;

&lt;P&gt;Please post the splunk query which calcualte the total duration of time spent in office&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:52:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320963#M175412</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2017-02-21T13:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320964#M175413</link>
      <description>&lt;P&gt;is that file in splunk, with extracted field names?&lt;/P&gt;

&lt;P&gt;can you run a search like &lt;CODE&gt;SwipeTime=*&lt;/CODE&gt; and get results? -if yes try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=yoursourcetypename|transaction Emp_No startswith=(Status="IN")  endswith=(Status="OUT") maxevents=2|stats sum(duration) as totalDuration by Emp_No
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 16:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320964#M175413</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-21T16:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320965#M175414</link>
      <description>&lt;P&gt;|inputlookup security.csv | rename "Emp No" as Emp_no "Swipe Status" as Status |transaction Emp_no startswith=(Status="Time IN")  endswith=(Status="Time OUT") maxevents=2|stats sum(duration) as totalDuration by Emp_no&lt;/P&gt;

&lt;P&gt;Executed above query but no result found.. anything missing&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:00:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320965#M175414</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2020-09-29T13:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320966#M175415</link>
      <description>&lt;P&gt;Hi @srinivasup - apologies, I had not realised you were loading these from a CSV. The issue with the searches above is that they rely on the _time variable to calculate duration. To solve this you need to set _time from the values in the CSV.  I have loaded your example into my test system and the following seems to work - (strangely the starts/ends with is not working as I had expected, but works fine without it).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup security.csv| rename "Emp No" as Emp_no "Swipe Status" as Status |eval time=Date." ".SwipeTime|eval _time=strptime(time, "%d/%m/%y %H:%M:%S")|transaction Emp_no maxevents=2|stats sum(duration) as totalDuration by Emp_no
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:34:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320966#M175415</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-21T20:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320967#M175416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I think this query is not giving exact results. If we can see the csv file, for one employee there are multiple Time IN and multiple TIme OUT values are associated. We need to calculate total time spent in office for each employee.&lt;/P&gt;

&lt;P&gt;After i executed the above query it is giving duration values. Do we need to convert them into human readable if yes how?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 10:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320967#M175416</guid>
      <dc:creator>srinivasup</dc:creator>
      <dc:date>2017-02-22T10:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Secuirty checks with help of splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320968#M175417</link>
      <description>&lt;P&gt;That is what its doing:&lt;BR /&gt;
Using your example CSV above when i run that search i get:&lt;BR /&gt;
    "Emp_no",totalDuration&lt;BR /&gt;
    111,12145&lt;BR /&gt;
    222,3807&lt;BR /&gt;
    333,3547&lt;BR /&gt;
(Total duration is seconds)&lt;/P&gt;

&lt;P&gt;Take user 333 (18:39:43-18:01:05) is 38:38 or 2318 seconds&lt;BR /&gt;
(19:04:01-18:43:32) is 20:29 or 1229 seconds.&lt;BR /&gt;
2318 + 1229 = 3547seconds clocked in.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 11:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Secuirty-checks-with-help-of-splunk/m-p/320968#M175417</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-22T11:10:13Z</dc:date>
    </item>
  </channel>
</rss>

