<?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 find the time duration between logins in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314249#M94043</link>
    <description>&lt;P&gt;Use &lt;CODE&gt;streamstats&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query that gets all the logins
| sort 0 _time 
| bin _time as day span=1d
| streamstats current=f last(_time) as lasttime by customer day
| eval duration= _time - lasttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you have your duration between logins.  How to calculate the average depends on what you mean.&lt;/P&gt;

&lt;P&gt;This is the average time between logins, averaged on a login basis. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the average time between logins, averaged on a customer basis. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as duration by customer
| stats avg(duration) as duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Nov 2017 20:53:22 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-11-28T20:53:22Z</dc:date>
    <item>
      <title>How to find the time duration between logins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314248#M94042</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a fun one.... fun being the operative word  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  I have data that looks like the below when someone logs in.  I've extracted out the exr value which is unique when a customer logs in.  What I'd like to do is track the time duration between 1 login for a customer and the next.&lt;/P&gt;

&lt;P&gt;example.  customer with exr of exr395164 logs in at 1:10 pm does some things then logs out, then logs in again at 2:15 pm.  I'd like to calculate the 1:05 min and then get an average of all customer times between logins.&lt;/P&gt;

&lt;P&gt;Any things?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   [-] 
     Properties:    {   [-] 
         args:  [   [-] 
         {"accountId":"exr395164","customerId":"3555"}  
        ]   
         category:   Event  
         index:  1  
    }   
     analyticType:   CustomAnalytic 
     buildTarget:    blah   
     clientSessionId:    DXFMTCJ-BGKVKYL    
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 20:45:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314248#M94042</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-11-28T20:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time duration between logins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314249#M94043</link>
      <description>&lt;P&gt;Use &lt;CODE&gt;streamstats&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query that gets all the logins
| sort 0 _time 
| bin _time as day span=1d
| streamstats current=f last(_time) as lasttime by customer day
| eval duration= _time - lasttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you have your duration between logins.  How to calculate the average depends on what you mean.&lt;/P&gt;

&lt;P&gt;This is the average time between logins, averaged on a login basis. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the average time between logins, averaged on a customer basis. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as duration by customer
| stats avg(duration) as duration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Nov 2017 20:53:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314249#M94043</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-28T20:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time duration between logins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314250#M94044</link>
      <description>&lt;P&gt;Hi DalJeanis,&lt;/P&gt;

&lt;P&gt;That is pretty slick.....  Now I can glue back the clumps of hair &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;   One quick (hopefully) question.....  the duration is in seconds?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 21:09:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314250#M94044</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-11-28T21:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time duration between logins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314251#M94045</link>
      <description>&lt;P&gt;@dbcase - yes, epoch time is in seconds, so subtracting two epoch times gives you an answer in seconds.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 22:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314251#M94045</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-28T22:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the time duration between logins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314252#M94046</link>
      <description>&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 14:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-the-time-duration-between-logins/m-p/314252#M94046</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-11-29T14:42:44Z</dc:date>
    </item>
  </channel>
</rss>

