<?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 do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222933#M43690</link>
    <description>&lt;P&gt;The way sundareshr  is doing below, sum by UserID in case you have a field like this.&lt;/P&gt;

&lt;P&gt;Go through his response, I think it can help you more than mine. Mine is just for the time, but he is checking when it's a timeout and set it as logout, and streamstats statement will work for time calculation.&lt;/P&gt;

&lt;P&gt;Anyway, write me again if anything! I will be glad to help&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2016 08:07:33 GMT</pubDate>
    <dc:creator>marina_rovira</dc:creator>
    <dc:date>2016-04-29T08:07:33Z</dc:date>
    <item>
      <title>How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222927#M43684</link>
      <description>&lt;P&gt;My agents log in and out of our system several times in a given shift and I need to aggregate the total time they spend logged in.  There is one event captured for successful log in and two for log out (one for idle timeout and one for log out).&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 20:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222927#M43684</guid>
      <dc:creator>MDSplunkNinja</dc:creator>
      <dc:date>2016-04-26T20:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222928#M43685</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm always using this sentence to find the total time for ticket handling:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval diference=strptime('ClosureAt', "%d %b %Y %T %Z")-strptime('CreatedAt', "%d %b %Y %T %Z")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;IT transforms the timestamp (type: "%d %b %Y %T %Z") in epoch time and calculates the difference. If you want an average, It's better to calculate it with epoch type and then make the change with this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval "Time average"=tostring(round(avg,0), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I know there is a statement called transaction that can help you better for this, but since I don't use it, I can not explain you how to do it. (See documentation here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.0/SearchReference/Transaction&lt;/A&gt; )&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 09:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222928#M43685</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2016-04-27T09:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222929#M43686</link>
      <description>&lt;P&gt;How are you aggregating the total handling time per agent?  Have you been able to do that within your search or do you have to do that in excel?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 13:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222929#M43686</guid>
      <dc:creator>MDSplunkNinja</dc:creator>
      <dc:date>2016-04-27T13:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222930#M43687</link>
      <description>&lt;P&gt;What do you mean per agent?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 14:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222930#M43687</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2016-04-27T14:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222931#M43688</link>
      <description>&lt;P&gt;Agents=Users.  I need to get the total time spent logged in to the system per user in a given shift or week or month.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 13:56:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222931#M43688</guid>
      <dc:creator>MDSplunkNinja</dc:creator>
      <dc:date>2016-04-28T13:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222932#M43689</link>
      <description>&lt;P&gt;Maybe this will help give you some ideas... (this is psuedo code, please tweak to your data set)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     index=* login OR logout OR timeout | rex "(?&amp;lt;action&amp;gt;login|logout|timeout)" | eval action=if(action=="logout" OR action=="timeout", "logout", action) | reverse | streamstats count as session by userid action | sort userid session | streamstats window=1 range(_time) as dur by userid session | stats sum(dur) as duration by userid
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2016 16:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222932#M43689</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-28T16:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222933#M43690</link>
      <description>&lt;P&gt;The way sundareshr  is doing below, sum by UserID in case you have a field like this.&lt;/P&gt;

&lt;P&gt;Go through his response, I think it can help you more than mine. Mine is just for the time, but he is checking when it's a timeout and set it as logout, and streamstats statement will work for time calculation.&lt;/P&gt;

&lt;P&gt;Anyway, write me again if anything! I will be glad to help&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 08:07:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222933#M43690</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2016-04-29T08:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222934#M43691</link>
      <description>&lt;P&gt;sundareshr...this is looking pretty good.  I am getting back data by user but all of the durations are "0".  Did I miss a variable in this search that was "psuedo"?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=XXXXXXXXXXXXXX client=XXXXXXXXX (SUCCESSFUL_UI_LOGIN OR LOGOUT_UI_TIMEOUT OR LOGOUT_UI_REGULAR) | rex "(?SUCCESSFUL_UI_LOGIN|LOGOUT_UI_TIMEOUT|LOGOUT_UI_REGULAR)" | eval action=if(action=="LOGOUT_UI_TIMEOUT" OR action=="LOGOUT_UI_REGULAR", "logout", action) | reverse | streamstats count as session by normalizedUsername action | sort normalizedUsername session | streamstats window=1 range(_time) as dur by normalizedUsername session | stats sum(dur) as duration by normalizedUsername
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2016 13:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222934#M43691</guid>
      <dc:creator>MDSplunkNinja</dc:creator>
      <dc:date>2016-04-29T13:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I write a search to aggregate the difference between timestamps of disparate login and logout events by user ID over a given period of time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222935#M43692</link>
      <description>&lt;P&gt;Thank you Sundareshr and Marina for your help.  Here is what I was able to have success with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=XXXXXXXXXXXX client=XXXXXXXX (SUCCESSFUL_UI_LOGIN OR LOGOUT_UI_TIMEOUT OR LOGOUT_UI_REGULAR) | rex "(?SUCCESSFUL_UI_LOGIN|LOGOUT_UI_TIMEOUT|LOGOUT_UI_REGULAR)" | eval action=if(action=="LOGOUT_UI_TIMEOUT" OR action=="LOGOUT_UI_REGULAR", "logout", action) | transaction count as session by normalizedUsername action maxpause=1s | sort normalizedUsername session | transaction range(_time) as duration by normalizedUsername session startswith="SUCCESSFUL_UI_LOGIN" endswith="logout" | stats sum(duration) as duration by normalizedUsername
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 May 2016 19:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-write-a-search-to-aggregate-the-difference-between/m-p/222935#M43692</guid>
      <dc:creator>MDSplunkNinja</dc:creator>
      <dc:date>2016-05-09T19:50:43Z</dc:date>
    </item>
  </channel>
</rss>

