<?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: sum multiple session duration in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472441#M132929</link>
    <description>&lt;P&gt;Latest Query(To aggregate per day):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="user,dest_ip,bytes,start_time,end_time
A,10.10.10.10,35980247,24/01/2020 14:02,25/01/2020 01:18
A,10.10.10.10,3797665,24/01/2020 14:02,24/01/2020 15:19
A,10.10.10.10,552,24/01/2020 14:14,24/01/2020 14:15
A,10.10.10.10,3200,24/01/2020 14:01,24/01/2020 14:02
A,10.10.10.10,11373297,23/01/2020 13:57,24/01/2020 00:26
A,10.10.10.10,73590782,23/01/2020 09:59,23/01/2020 23:31
A,10.10.10.10,1203724,23/01/2020 13:57,23/01/2020 14:26
A,10.10.10.10,3134,23/01/2020 13:57,23/01/2020 13:57
A,10.10.10.10,8302783,23/01/2020 09:59,23/01/2020 13:31
A,10.10.10.10,276,23/01/2020 10:20,23/01/2020 10:20
A,10.10.10.10,3104,23/01/2020 09:58,23/01/2020 09:59
A,10.10.10.10,3054,23/01/2020 09:59,23/01/2020 09:59 
B,10.10.10.2,4859519,17/01/2020 14:21,17/01/2020 17:19
B,10.10.10.2,3370174,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,238523,17/01/2020 14:21,17/01/2020 16:19
B,10.10.10.2,3166705,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,2783036,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,3174766,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,552,17/01/2020 14:33,17/01/2020 14:34
B,10.10.10.2,24396,17/01/2020 15:56,17/01/2020 15:59
B,10.10.10.2,675660,17/01/2020 15:57,17/01/2020 16:33
B,10.10.10.2,162019,17/01/2020 15:57,17/01/2020 16:05
B,10.10.10.2,6388,17/01/2020 15:57,17/01/2020 15:59
B,10.10.10.2,398887,17/01/2020 16:00,17/01/2020 16:13
B,10.10.10.2,294,17/01/2020 16:00,17/01/2020 16:00
B,10.10.10.2,35324,17/01/2020 16:01,17/01/2020 16:04
B,10.10.10.2,294,17/01/2020 16:06,17/01/2020 16:07
B,10.10.10.2,181888,17/01/2020 16:11,17/01/2020 17:07
B,10.10.10.2,25668,17/01/2020 16:11,17/01/2020 16:14
B,10.10.10.2,517341,17/01/2020 16:19,17/01/2020 16:33
B,10.10.10.2,518877,17/01/2020 16:19,17/01/2020 16:33
B,10.10.10.2,80488,17/01/2020 16:27,17/01/2020 16:33
B,10.10.10.2,294,17/01/2020 16:27,17/01/2020 16:28
B,10.10.10.2,294,17/01/2020 16:27,17/01/2020 16:28
B,10.10.10.2,190050,17/01/2020 16:28,17/01/2020 16:33
B,10.10.10.2,39429,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,158281,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,39731,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,40338,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,100225,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,23526,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,28910,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,40860,17/01/2020 16:39,17/01/2020 16:43
B,10.10.10.2,14456,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,15816,17/01/2020 16:39,17/01/2020 16:42
C,10.10.10.2,6354,24/01/2020 13:36,24/01/2020 13:36
C,10.10.10.2,552,24/01/2020 13:55,24/01/2020 13:55
C,10.10.10.2,82751,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,254943,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,56569,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,104603,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,88522,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,168563,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,11535,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,8114,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,4691,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,25653,27/01/2020 09:07,27/01/2020 09:21
C,10.10.10.2,66339,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,52219,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,26527,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,7349,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,19109,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,20854,27/01/2020 09:09,27/01/2020 09:11
D,10.10.10.3,46783593,20/01/2020 15:27,20/01/2020 15:52
D,10.10.10.4,49106343,20/01/2020 15:27,20/01/2020 16:23
D,10.10.10.5,1033049,20/01/2020 15:38,20/01/2020 16:23
D,10.10.10.6,287151,20/01/2020 16:23,20/01/2020 16:24
D,10.10.10.4,132,20/01/2020 16:24,20/01/2020 16:24
D,10.10.10.4,62,20/01/2020 16:24,20/01/2020 16:24
D,10.10.10.5,4405811,20/01/2020 16:24,20/01/2020 16:59
D,10.10.10.4,18716525,20/01/2020 16:24,20/01/2020 16:44
D,10.10.10.7,40444,21/01/2020 09:21,21/01/2020 09:22
D,10.10.10.7,173988,21/01/2020 09:22,21/01/2020 09:24
D,10.10.10.7,2755,21/01/2020 09:24,21/01/2020 09:24
D,10.10.10.3,1148,21/01/2020 09:45,21/01/2020 09:46
D,10.10.10.3,7131,21/01/2020 09:46,21/01/2020 09:54
D,10.10.10.3,35138614,21/01/2020 09:54,21/01/2020 10:47" 
| multikv forceheader=1 
| table user,dest_ip,bytes,start_time,end_time 
| foreach *_time 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m/%Y %H:%M")) 
    | eval end_time=end_time+60] 
| sort user start_time
| eval user_dest=user.":".dest_ip
| streamstats current=f min(start_time) as p_start max(end_time) as t_end by user_dest 
| eval change_flag= if(t_end &amp;lt;= start_time,"over",NULL) 
| streamstats count(eval(change_flag="over")) as session by user_dest 
| stats min(start_time) as start_time max(end_time) as end_time by user_dest session 
| eval duration = end_time - start_time
| eval date=if(strftime(start_time,"%d")!=strftime(end_time,"%d"),mvrange(tonumber(strftime(start_time,"%d")),tonumber(strftime(end_time,"%d"))+1),strftime(start_time,"%d")) 
| mvexpand date
| eval time_d =round(relative_time(start_time,"+1d@d")) 
| eval duration=if(date=tonumber(strftime(start_time,"%d")), time_d - start_time,start_time + duration - time_d) 
| stats sum(duration) as duration by date user_dest 
| table user_dest duration date 
| eval duration=replace(tostring(duration,"duration"),"(\d+)\:(\d+)\:(\d+)","\1h \2min \3s") 
| foreach *_* 
    [ eval &amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;=mvindex(split(user_dest,":"),0) 
    | eval &amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;=mvindex(split(user_dest,":"),1)] 
| table user dest duration date
| sort user dest date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Precondition:&lt;/P&gt;

&lt;P&gt;Since &lt;EM&gt;start_time&lt;/EM&gt; and &lt;EM&gt;end_time&lt;/EM&gt; are the same, and &lt;CODE&gt;strptime&lt;/CODE&gt; is difficult to make duration, 60sec is added to &lt;EM&gt;end_time&lt;/EM&gt; uniformly.&lt;/P&gt;

&lt;P&gt;Way of thinking:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Until end_time &amp;lt; start_time , same session par user and dest_ip.&lt;/LI&gt;
&lt;LI&gt;In the session, find minimum &lt;EM&gt;start_time&lt;/EM&gt; and maximum  &lt;EM&gt;end_time&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;For each user ,dest_ip and session, calculate duration.&lt;/LI&gt;
&lt;LI&gt;For par a day, create multivalue of days.&lt;/LI&gt;
&lt;LI&gt;expand days.&lt;/LI&gt;
&lt;LI&gt;Aggregate user and day.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;This is hard issue.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval date=if(strftime(start_time,"%d")!=strftime(end_time,"%d"),mvrange(tonumber(strftime(start_time,"%d")),tonumber(strftime(end_time,"%d"))+1),strftime(start_time,"%d")) 
| mvexpand date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to praise myself here.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;note:&lt;/CODE&gt; Since I do not consider the period between 31st and 1st, we need to create fields for display if necessary.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 04:13:51 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-09-30T04:13:51Z</dc:date>
    <item>
      <title>sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472429#M132917</link>
      <description>&lt;P&gt;Hi at all,&lt;BR /&gt;
I have a very strange problem that I'm trying to solve.&lt;BR /&gt;
I have a data source with the following fields:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;user&lt;/LI&gt;
&lt;LI&gt;dest_ip&lt;/LI&gt;
&lt;LI&gt;start_time&lt;/LI&gt;
&lt;LI&gt;end_time&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I have to understand how long a user used network connections in each hour.&lt;BR /&gt;
the problem is that I could have parallel sessions that I cannor sum because I could have more than 60 minutes of connection in one hour and it isn't acceptable.&lt;BR /&gt;
In addition I could have a connection from 10.05 to 10.10 and another from 10.45 to 10.50 so I cannot take the start of the first and the end of the second.&lt;/P&gt;

&lt;P&gt;Someone can hint how to approach the problem?&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 12:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472429#M132917</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-14T12:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472430#M132918</link>
      <description>&lt;P&gt;Can you provide sample logs?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 04:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472430#M132918</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-15T04:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472431#M132919</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="user,dest_ip,start_time,end_time
A,X.X.X.X,2020/02/13 10:05,2020/02/13 10:10
A,X.X.X.X,2020/02/13 10:45,2020/02/13 10:50"
| multikv forceheader=1
| table user,dest_ip,start_time,end_time
| foreach *_time [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "%Y/%m/%d %H:%M")]
| fieldformat start_time = strftime(start_time, "%Y/%m/%d %H:%M") 
| fieldformat end_time = strftime(end_time, "%Y/%m/%d %H:%M") 
| addinfo
| eval duration = coalesce(end_time,info_max_time) - coalesce(start_time,info_min_time)
| eventstats sum(duration) as total_duration by user
| table user,dest_ip,start_time,end_time duration total_duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hi, @gcusello &lt;BR /&gt;
Anyway, I made a query.&lt;BR /&gt;
I considered the case of starting and ending outside the range of time piker.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 04:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472431#M132919</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-15T04:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472432#M132920</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;,&lt;BR /&gt;
Thank you for your help.&lt;BR /&gt;
The problem isn't to find the duration of each transaction because in each row I have start_time and end_time, the problem is that I usually have more parallel sessions so if I sum all duration I have more than the time period, instead I need to know how long the user used the connection.&lt;/P&gt;

&lt;P&gt;Below, you can find some example of my data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user dest_ip    bytes   start_time  end_time
A   10.10.10.1  330 16/01/2020 09:30    16/01/2020 09:31
B   10.10.10.2  4859519 17/01/2020 14:21    17/01/2020 17:19
B   10.10.10.2  3370174 17/01/2020 14:21    17/01/2020 15:39
B   10.10.10.2  238523  17/01/2020 14:21    17/01/2020 16:19
B   10.10.10.2  3166705 17/01/2020 14:21    17/01/2020 15:39
B   10.10.10.2  2783036 17/01/2020 14:21    17/01/2020 15:39
B   10.10.10.2  3174766 17/01/2020 14:21    17/01/2020 15:39
B   10.10.10.2  552 17/01/2020 14:33    17/01/2020 14:34
B   10.10.10.2  24396   17/01/2020 15:56    17/01/2020 15:59
B   10.10.10.2  675660  17/01/2020 15:57    17/01/2020 16:33
B   10.10.10.2  162019  17/01/2020 15:57    17/01/2020 16:05
B   10.10.10.2  6388    17/01/2020 15:57    17/01/2020 15:59
B   10.10.10.2  398887  17/01/2020 16:00    17/01/2020 16:13
B   10.10.10.2  294 17/01/2020 16:00    17/01/2020 16:00
B   10.10.10.2  35324   17/01/2020 16:01    17/01/2020 16:04
B   10.10.10.2  294 17/01/2020 16:06    17/01/2020 16:07
B   10.10.10.2  181888  17/01/2020 16:11    17/01/2020 17:07
B   10.10.10.2  25668   17/01/2020 16:11    17/01/2020 16:14
B   10.10.10.2  517341  17/01/2020 16:19    17/01/2020 16:33
B   10.10.10.2  518877  17/01/2020 16:19    17/01/2020 16:33
B   10.10.10.2  80488   17/01/2020 16:27    17/01/2020 16:33
B   10.10.10.2  294 17/01/2020 16:27    17/01/2020 16:28
B   10.10.10.2  294 17/01/2020 16:27    17/01/2020 16:28
B   10.10.10.2  190050  17/01/2020 16:28    17/01/2020 16:33
B   10.10.10.2  39429   17/01/2020 16:36    17/01/2020 16:39
B   10.10.10.2  158281  17/01/2020 16:36    17/01/2020 16:39
B   10.10.10.2  39731   17/01/2020 16:36    17/01/2020 16:39
B   10.10.10.2  40338   17/01/2020 16:36    17/01/2020 16:39
B   10.10.10.2  100225  17/01/2020 16:36    17/01/2020 16:39
B   10.10.10.2  23526   17/01/2020 16:39    17/01/2020 16:42
B   10.10.10.2  28910   17/01/2020 16:39    17/01/2020 16:42
B   10.10.10.2  40860   17/01/2020 16:39    17/01/2020 16:43
B   10.10.10.2  14456   17/01/2020 16:39    17/01/2020 16:42
B   10.10.10.2  15816   17/01/2020 16:39    17/01/2020 16:42
C   10.10.10.2  6354    24/01/2020 13:36    24/01/2020 13:36
C   10.10.10.2  552 24/01/2020 13:55    24/01/2020 13:55
C   10.10.10.2  82751   27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  254943  27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  56569   27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  104603  27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  88522   27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  168563  27/01/2020 09:06    27/01/2020 09:09
C   10.10.10.2  11535   27/01/2020 09:07    27/01/2020 09:09
C   10.10.10.2  8114    27/01/2020 09:07    27/01/2020 09:09
C   10.10.10.2  4691    27/01/2020 09:07    27/01/2020 09:09
C   10.10.10.2  25653   27/01/2020 09:07    27/01/2020 09:21
C   10.10.10.2  66339   27/01/2020 09:09    27/01/2020 09:11
C   10.10.10.2  52219   27/01/2020 09:09    27/01/2020 09:11
C   10.10.10.2  26527   27/01/2020 09:09    27/01/2020 09:11
C   10.10.10.2  7349    27/01/2020 09:09    27/01/2020 09:11
C   10.10.10.2  19109   27/01/2020 09:09    27/01/2020 09:11
C   10.10.10.2  20854   27/01/2020 09:09    27/01/2020 09:11
D   10.10.10.3  46783593    20/01/2020 15:27    20/01/2020 15:52
D   10.10.10.4  49106343    20/01/2020 15:27    20/01/2020 16:23
D   10.10.10.5  1033049 20/01/2020 15:38    20/01/2020 16:23
D   10.10.10.6  287151  20/01/2020 16:23    20/01/2020 16:24
D   10.10.10.4  132 20/01/2020 16:24    20/01/2020 16:24
D   10.10.10.4  62  20/01/2020 16:24    20/01/2020 16:24
D   10.10.10.5  4405811 20/01/2020 16:24    20/01/2020 16:59
D   10.10.10.4  18716525    20/01/2020 16:24    20/01/2020 16:44
D   10.10.10.7  40444   21/01/2020 09:21    21/01/2020 09:22
D   10.10.10.7  173988  21/01/2020 09:22    21/01/2020 09:24
D   10.10.10.7  2755    21/01/2020 09:24    21/01/2020 09:24
D   10.10.10.3  1148    21/01/2020 09:45    21/01/2020 09:46
D   10.10.10.3  7131    21/01/2020 09:46    21/01/2020 09:54
D   10.10.10.3  35138614    21/01/2020 09:54    21/01/2020 10:47
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:12:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472432#M132920</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T04:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472433#M132921</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; C    10.10.10.2    6354    24/01/2020 13:36    24/01/2020 13:36
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does this row has seconds? &lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 09:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472433#M132921</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-15T09:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472434#M132922</link>
      <description>&lt;P&gt;No time format is %d/%m/%Y %H:%M&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 15:28:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472434#M132922</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-15T15:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472435#M132923</link>
      <description>&lt;P&gt;does the dest_ip matter? is it per user per dest_ip or just per user ?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472435#M132923</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-09-30T04:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472436#M132924</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;Give this a shot, slight tweaking might be needed&lt;/P&gt;

&lt;P&gt;base_ search for events, time converted to epoch.&lt;BR /&gt;
this query is duration per user. if you need per user per dest_ip, please add dest_ip to all the group_by and sort&lt;BR /&gt;
What i'm doing here is basically removing overlapping timelines and grouping them into one continuous session&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base_search
| fields user, dest_ip, start_time, end_time
| sort user, dest_ip, -start_time
| streamstats max(start_time) as next_start by user, dest_ip window=1 reset_on_change=true current=false
| sort user, dest_ip, start_time
| eval next_start=coalesce(next_start, start_time), row_group=1
| where end_time&amp;gt;next_start
| streamstats sum(row_group) as row_group by user, dest_ip reset_on_change=true 
| eval row_group=(floor(coalesce(row_group,0)/2))
| stats min(start_time) as start_time, max(end_time) as end_time by user, dest_ip, row_group
| eval duration=end_time-start_time
| rename start_time as _time
| bucket span=1h
| stats sum(duration) as duration by user, dest_ip, _time
| eval over_time=if(duration&amp;gt;60, duration-60, 0)
| streamstats max(over_time) as add_time by user, dest_ip window=1 reset_on_change=true current=false
| fillnull value=0 add_time
| eval duration=duration + add_time - over_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472436#M132924</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-09-30T04:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472437#M132925</link>
      <description>&lt;P&gt;Hi @arjunpkishore5,&lt;BR /&gt;
Thank you for your help, I think that your approach is correct but this isn't yet the final solution!&lt;BR /&gt;
replacing the last row of the search with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | bin span=1h start_time
  | chart sum(duration) as duration OVER start_time BY user
  | eval start_time=strftime(start_time,"%Y-%m-%d %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I see that sometimes (user B at 2020-01-17 14:00) there are more than 3600 seconds in an hour and this is impossible.&lt;/P&gt;

&lt;P&gt;Can you give more ideas? Anyway, I'll continue to explore your solution.&lt;/P&gt;

&lt;P&gt;Ciao and thank you.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 18:10:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472437#M132925</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-16T18:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472438#M132926</link>
      <description>&lt;P&gt;per user per dest_ip.&lt;BR /&gt;
Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 18:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472438#M132926</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-16T18:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472439#M132927</link>
      <description>&lt;P&gt;Edited my answer to accommodate this condition (lines 13 onward) i'm calculating over_time which is the duration over 60 and adding it to the next hours time. I haven't tested the query, just going with the algorithm in my head and converting it to code. Some fixes may be needed. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 05:07:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472439#M132927</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-02-17T05:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472440#M132928</link>
      <description>&lt;P&gt;I also added dest_ip to the group by &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 05:08:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472440#M132928</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-02-17T05:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472441#M132929</link>
      <description>&lt;P&gt;Latest Query(To aggregate per day):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="user,dest_ip,bytes,start_time,end_time
A,10.10.10.10,35980247,24/01/2020 14:02,25/01/2020 01:18
A,10.10.10.10,3797665,24/01/2020 14:02,24/01/2020 15:19
A,10.10.10.10,552,24/01/2020 14:14,24/01/2020 14:15
A,10.10.10.10,3200,24/01/2020 14:01,24/01/2020 14:02
A,10.10.10.10,11373297,23/01/2020 13:57,24/01/2020 00:26
A,10.10.10.10,73590782,23/01/2020 09:59,23/01/2020 23:31
A,10.10.10.10,1203724,23/01/2020 13:57,23/01/2020 14:26
A,10.10.10.10,3134,23/01/2020 13:57,23/01/2020 13:57
A,10.10.10.10,8302783,23/01/2020 09:59,23/01/2020 13:31
A,10.10.10.10,276,23/01/2020 10:20,23/01/2020 10:20
A,10.10.10.10,3104,23/01/2020 09:58,23/01/2020 09:59
A,10.10.10.10,3054,23/01/2020 09:59,23/01/2020 09:59 
B,10.10.10.2,4859519,17/01/2020 14:21,17/01/2020 17:19
B,10.10.10.2,3370174,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,238523,17/01/2020 14:21,17/01/2020 16:19
B,10.10.10.2,3166705,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,2783036,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,3174766,17/01/2020 14:21,17/01/2020 15:39
B,10.10.10.2,552,17/01/2020 14:33,17/01/2020 14:34
B,10.10.10.2,24396,17/01/2020 15:56,17/01/2020 15:59
B,10.10.10.2,675660,17/01/2020 15:57,17/01/2020 16:33
B,10.10.10.2,162019,17/01/2020 15:57,17/01/2020 16:05
B,10.10.10.2,6388,17/01/2020 15:57,17/01/2020 15:59
B,10.10.10.2,398887,17/01/2020 16:00,17/01/2020 16:13
B,10.10.10.2,294,17/01/2020 16:00,17/01/2020 16:00
B,10.10.10.2,35324,17/01/2020 16:01,17/01/2020 16:04
B,10.10.10.2,294,17/01/2020 16:06,17/01/2020 16:07
B,10.10.10.2,181888,17/01/2020 16:11,17/01/2020 17:07
B,10.10.10.2,25668,17/01/2020 16:11,17/01/2020 16:14
B,10.10.10.2,517341,17/01/2020 16:19,17/01/2020 16:33
B,10.10.10.2,518877,17/01/2020 16:19,17/01/2020 16:33
B,10.10.10.2,80488,17/01/2020 16:27,17/01/2020 16:33
B,10.10.10.2,294,17/01/2020 16:27,17/01/2020 16:28
B,10.10.10.2,294,17/01/2020 16:27,17/01/2020 16:28
B,10.10.10.2,190050,17/01/2020 16:28,17/01/2020 16:33
B,10.10.10.2,39429,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,158281,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,39731,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,40338,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,100225,17/01/2020 16:36,17/01/2020 16:39
B,10.10.10.2,23526,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,28910,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,40860,17/01/2020 16:39,17/01/2020 16:43
B,10.10.10.2,14456,17/01/2020 16:39,17/01/2020 16:42
B,10.10.10.2,15816,17/01/2020 16:39,17/01/2020 16:42
C,10.10.10.2,6354,24/01/2020 13:36,24/01/2020 13:36
C,10.10.10.2,552,24/01/2020 13:55,24/01/2020 13:55
C,10.10.10.2,82751,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,254943,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,56569,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,104603,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,88522,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,168563,27/01/2020 09:06,27/01/2020 09:09
C,10.10.10.2,11535,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,8114,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,4691,27/01/2020 09:07,27/01/2020 09:09
C,10.10.10.2,25653,27/01/2020 09:07,27/01/2020 09:21
C,10.10.10.2,66339,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,52219,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,26527,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,7349,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,19109,27/01/2020 09:09,27/01/2020 09:11
C,10.10.10.2,20854,27/01/2020 09:09,27/01/2020 09:11
D,10.10.10.3,46783593,20/01/2020 15:27,20/01/2020 15:52
D,10.10.10.4,49106343,20/01/2020 15:27,20/01/2020 16:23
D,10.10.10.5,1033049,20/01/2020 15:38,20/01/2020 16:23
D,10.10.10.6,287151,20/01/2020 16:23,20/01/2020 16:24
D,10.10.10.4,132,20/01/2020 16:24,20/01/2020 16:24
D,10.10.10.4,62,20/01/2020 16:24,20/01/2020 16:24
D,10.10.10.5,4405811,20/01/2020 16:24,20/01/2020 16:59
D,10.10.10.4,18716525,20/01/2020 16:24,20/01/2020 16:44
D,10.10.10.7,40444,21/01/2020 09:21,21/01/2020 09:22
D,10.10.10.7,173988,21/01/2020 09:22,21/01/2020 09:24
D,10.10.10.7,2755,21/01/2020 09:24,21/01/2020 09:24
D,10.10.10.3,1148,21/01/2020 09:45,21/01/2020 09:46
D,10.10.10.3,7131,21/01/2020 09:46,21/01/2020 09:54
D,10.10.10.3,35138614,21/01/2020 09:54,21/01/2020 10:47" 
| multikv forceheader=1 
| table user,dest_ip,bytes,start_time,end_time 
| foreach *_time 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m/%Y %H:%M")) 
    | eval end_time=end_time+60] 
| sort user start_time
| eval user_dest=user.":".dest_ip
| streamstats current=f min(start_time) as p_start max(end_time) as t_end by user_dest 
| eval change_flag= if(t_end &amp;lt;= start_time,"over",NULL) 
| streamstats count(eval(change_flag="over")) as session by user_dest 
| stats min(start_time) as start_time max(end_time) as end_time by user_dest session 
| eval duration = end_time - start_time
| eval date=if(strftime(start_time,"%d")!=strftime(end_time,"%d"),mvrange(tonumber(strftime(start_time,"%d")),tonumber(strftime(end_time,"%d"))+1),strftime(start_time,"%d")) 
| mvexpand date
| eval time_d =round(relative_time(start_time,"+1d@d")) 
| eval duration=if(date=tonumber(strftime(start_time,"%d")), time_d - start_time,start_time + duration - time_d) 
| stats sum(duration) as duration by date user_dest 
| table user_dest duration date 
| eval duration=replace(tostring(duration,"duration"),"(\d+)\:(\d+)\:(\d+)","\1h \2min \3s") 
| foreach *_* 
    [ eval &amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;=mvindex(split(user_dest,":"),0) 
    | eval &amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;=mvindex(split(user_dest,":"),1)] 
| table user dest duration date
| sort user dest date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Precondition:&lt;/P&gt;

&lt;P&gt;Since &lt;EM&gt;start_time&lt;/EM&gt; and &lt;EM&gt;end_time&lt;/EM&gt; are the same, and &lt;CODE&gt;strptime&lt;/CODE&gt; is difficult to make duration, 60sec is added to &lt;EM&gt;end_time&lt;/EM&gt; uniformly.&lt;/P&gt;

&lt;P&gt;Way of thinking:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Until end_time &amp;lt; start_time , same session par user and dest_ip.&lt;/LI&gt;
&lt;LI&gt;In the session, find minimum &lt;EM&gt;start_time&lt;/EM&gt; and maximum  &lt;EM&gt;end_time&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;For each user ,dest_ip and session, calculate duration.&lt;/LI&gt;
&lt;LI&gt;For par a day, create multivalue of days.&lt;/LI&gt;
&lt;LI&gt;expand days.&lt;/LI&gt;
&lt;LI&gt;Aggregate user and day.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;This is hard issue.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval date=if(strftime(start_time,"%d")!=strftime(end_time,"%d"),mvrange(tonumber(strftime(start_time,"%d")),tonumber(strftime(end_time,"%d"))+1),strftime(start_time,"%d")) 
| mvexpand date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to praise myself here.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;note:&lt;/CODE&gt; Since I do not consider the period between 31st and 1st, we need to create fields for display if necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:13:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472441#M132929</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-09-30T04:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472442#M132930</link>
      <description>&lt;P&gt;To aggregate par user and dest_ip but no consider over a day:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table user,dest_ip,bytes,start_time,end_time 
| foreach *_time 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m/%Y %H:%M")) 
    | eval end_time=end_time+60] 
| eval user_dest=user.":".dest_ip 
| streamstats current=f min(start_time) as p_start max(end_time) as t_end by user_dest 
| eval change_flag= if(t_end &amp;lt;= start_time,"over",NULL) 
| streamstats count(eval(change_flag="over")) as session by user_dest 
| stats min(start_time) as start_time max(end_time) as end_time by user_dest session 
| eval duration = end_time - start_time
| eval time_tmp=if(strftime(start_time,"%H")!=strftime(end_time,"%H"),mvrange(tonumber(strftime(start_time,"%H")),tonumber(strftime(end_time,"%H"))+1),0)
|mvexpand time_tmp
| eval duration_ph=case(time_tmp=0,duration
,tonumber(strftime(start_time,"%H"))=time_tmp,round(relative_time(start_time,"+1h@h")) - start_time
,tonumber(strftime(end_time,"%H"))=time_tmp,end_time - round(relative_time(end_time,"@h")) 
,true(),3600)
| eval _time = if(time_tmp=0,relative_time(start_time,"@h"), strptime(strftime(start_time,"%F")." ".time_tmp,"%F %H"))
| table _time duration_ph user_dest
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Feb 2020 19:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472442#M132930</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-17T19:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472443#M132931</link>
      <description>&lt;P&gt;Pre version:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....
| table user,dest_ip,bytes,start_time,end_time 
`comment("this is sample you provide. From here, the logic")`
| foreach *_time 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m/%Y %H:%M"))
    | eval end_time=end_time+60] 
| streamstats window=1 current=f list(start_time) as p_start list(end_time) as t_end by user
| eval change_flag= if(t_end &amp;lt;= start_time,"over",NULL)
| streamstats count(eval(change_flag="over")) as session by user
| stats min(start_time) as start_time max(end_time) as end_time by user session
| eval duration = end_time - start_time
| stats sum(duration) as duration by user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Precondition:&lt;/P&gt;

&lt;P&gt;Since &lt;EM&gt;start_time&lt;/EM&gt; and &lt;EM&gt;end_time&lt;/EM&gt; are the same, and &lt;CODE&gt;strptime&lt;/CODE&gt; is difficult to make duration, 60sec is added to &lt;EM&gt;end_time&lt;/EM&gt; uniformly.&lt;/P&gt;

&lt;P&gt;Way of thinking:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Until end_time &amp;lt; start_time , same session.&lt;/LI&gt;
&lt;LI&gt;In the session, find minimum &lt;EM&gt;start_time&lt;/EM&gt; and maximum  &lt;EM&gt;end_time&lt;/EM&gt;.&lt;/LI&gt;
&lt;LI&gt;For each user and session, calculate duration.&lt;/LI&gt;
&lt;LI&gt;Aggregated by user.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;It was a very rewarding issue.&lt;BR /&gt;
How about this?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472443#M132931</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-09-30T04:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472444#M132932</link>
      <description>&lt;P&gt;Hi  @to4kawa,&lt;BR /&gt;
Thank you for your help, I think that your approach is correct but this isn't yet the final solution!&lt;BR /&gt;
replacing the last row of the search with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | bin span=1h start_time
 | chart sum(duration) as duration OVER start_time BY user
 | eval start_time=strftime(start_time,"%Y-%m-%d %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I see that sometimes (user B at 2020-01-17 14:00) there are more than 3600 seconds in an hour and this is impossible.&lt;/P&gt;

&lt;P&gt;Can you give more ideas? Anyway, I'll continue to explore your solution.&lt;/P&gt;

&lt;P&gt;Ciao and thank you.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 19:14:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472444#M132932</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-17T19:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472445#M132933</link>
      <description>&lt;P&gt;hi, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; &lt;BR /&gt;
my query is made for aggregation between search range, not for aggregation par hour.&lt;BR /&gt;
It is not work well.&lt;/P&gt;

&lt;P&gt;For par dest_ip, &lt;BR /&gt;
we should modify &lt;CODE&gt;| eval change_flag= if(t_end &amp;lt;= start_time,"over",NULL)&lt;/CODE&gt;&lt;BR /&gt;
OR &lt;CODE&gt;| streamstats window=1 current=f list(start_time) as p_start list(end_time) as t_end by user dest_ip&lt;/CODE&gt; &lt;BR /&gt;
now, I can't try this. sorry.&lt;/P&gt;

&lt;P&gt;In my query, the duration of user B is from 17/01/2020 14:21 to 17/01/2020 17:19.&lt;BR /&gt;
many accesses are included in it.&lt;/P&gt;

&lt;P&gt;I'm not sure &lt;CODE&gt;par hour&lt;/CODE&gt;.&lt;BR /&gt;
In this case,&lt;BR /&gt;
14:00~ 15:00 39min&lt;BR /&gt;
15:00~ 16:00 60min&lt;BR /&gt;
16:00~ 17:00 60min&lt;BR /&gt;
17:00~ 18:00 19min&lt;BR /&gt;
Is this right?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:07:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472445#M132933</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-09-30T04:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472446#M132934</link>
      <description>&lt;P&gt;Hi @to4kawa,&lt;BR /&gt;
the check for hour is important to understand if the solution is correct because I cannot have more than 60 minutes in an hour.&lt;BR /&gt;
Anyway it's right the last position:&lt;BR /&gt;
14:00~ 15:00 39min&lt;BR /&gt;
15:00~ 16:00 60min&lt;BR /&gt;
16:00~ 17:00 60min&lt;BR /&gt;
17:00~ 18:00 19min&lt;BR /&gt;
I tried to implement on your code but I haven't succeeded yet.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 19:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472446#M132934</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-17T19:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472447#M132935</link>
      <description>&lt;P&gt;Hi @to4kawa,&lt;BR /&gt;
Your search is quite OK, I have only one issue: I need to divide results for days:&lt;BR /&gt;
I found that there could be connections that start in one day and and in the following, I need to divide durations by day.&lt;BR /&gt;
These are a subset of data to test this thing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bytes            dest_ip            end_time            start_time          user
35980247    10.10.10.10.    25/01/2020 01:18    24/01/2020 14:02    A
3797665 10.10.10.10.    24/01/2020 15:19    24/01/2020 14:02    A
552         10.10.10.10.    24/01/2020 14:15    24/01/2020 14:14    A
3200            10.10.10.10.    24/01/2020 14:02    24/01/2020 14:01    A
11373297    10.10.10.10.    24/01/2020 00:26    23/01/2020 13:57    A
73590782    10.10.10.10.    23/01/2020 23:31    23/01/2020 09:59    A
1203724 10.10.10.10.    23/01/2020 14:26    23/01/2020 13:57    A
3134            10.10.10.10.    23/01/2020 13:57    23/01/2020 13:57    A
8302783 10.10.10.10.    23/01/2020 13:31    23/01/2020 09:59    A
276         10.10.10.10.    23/01/2020 10:20    23/01/2020 10:20    A
3104            10.10.10.10.    23/01/2020 09:59    23/01/2020 09:58    A
3054            10.10.10.10.    23/01/2020 09:59    23/01/2020 09:59    A
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the your search I used:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; my_search
| foreach *_time [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = round(strptime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m/%Y %H:%M"))
| eval b_&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt; = strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',"%d/%m %H:%M")]
| table user dest_ip bytes b_start start_time b_end end_time
| streamstats min(start_time) as start_p max(end_time) as end_p by user
| streamstats min(eval(min(end_p,start_time))) as start_p  max(eval(max(end_p,end_time))) as end_p by user dest_ip
| table user dest_ip bytes b_start start_time start_p b_end end_time end_p
| eval start_check =nullif(start_time &amp;gt;= start_p AND end_time &amp;gt;= end_p,null())
| streamstats dc(eval(mvzip(start_p,end_p))) as flag
| dedup flag
| eval date=strftime(start_time,"%d")
| streamstats min(start_time) as start_p max(end_time) as end_p current=f by user dest_ip date
| reverse
| dedup start_time user
| reverse
| eval duration=end_time - start_time
| stats sum(duration) as duration max(date) as date by user dest_ip
| convert rmunit(duration) as diff
| eval diff=round(diff)
| eval difference=tostring(diff,"duration")
| eval difference = replace(difference,"(\d+)\:(\d+)\:(\d+)","\1h \2min \3s")
| table user dest_ip difference date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao and Thank you.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 19:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472447#M132935</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-02-17T19:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: sum multiple session duration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472448#M132936</link>
      <description>&lt;P&gt;hi @gcusello &lt;BR /&gt;
This is my latest query.&lt;BR /&gt;
So you made the tally on a daily basis.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 19:17:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sum-multiple-session-duration/m-p/472448#M132936</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-17T19:17:57Z</dc:date>
    </item>
  </channel>
</rss>

