<?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 calculate duration of a session to populate a summary index? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225064#M66354</link>
    <description>&lt;P&gt;First of all, you forgot the pipe ( &lt;CODE&gt;|&lt;/CODE&gt; ) before the &lt;CODE&gt;transaction&lt;/CODE&gt; command so that may be part of the problem; in any case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test1 | stats earliest(_time) AS earliest latest(_time) AS latest BY vendor_session_id | eval duration = tostring((latest-earliest), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 Apr 2016 19:38:47 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2016-04-28T19:38:47Z</dc:date>
    <item>
      <title>How to calculate duration of a session to populate a summary index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225062#M66352</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Background:&lt;/STRONG&gt;&lt;BR /&gt;
My data is being sent to a summary index.&lt;BR /&gt;
The search that populates the summary index is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test1 transaction vendor_session_id startswith="New session" endswith="Session deleted" | collect index=vendor-traffic-grp1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;** I've tried removing the statswith/endswith&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The Goal:&lt;/STRONG&gt;&lt;BR /&gt;
I need to simply calculate the duration of the session so I can throw it to a panel/table/dashboard/etc for all/any sessions I need to display... username, session, duration&lt;/P&gt;

&lt;P&gt;====================================&lt;BR /&gt;
I have read numerous posts, documents and tried a multitude of search methods: stats*, eval, event*, _time, transaction.. But I am unable to generate duration. &lt;/P&gt;

&lt;P&gt;The transaction command builds the duration field which is correct. I've tried to run the transaction again in the summary index, but the duration is zero or off by a few seconds so I have attempted to calculate the session duration using other search commands with no luck. It almost seems like pushing the data into the summary index wipes the original timestamp. I was thinking its a timestamp parsing issue ( prefix the &amp;lt;141&amp;gt; and (express the time) and lookahead 21'ish) but I am unable to change the timestamp in the summary index sourcetype  "Stash" wish is autocreated when using the summary index. Any advice or direction would be greatly appreciated! &lt;/P&gt;

&lt;P&gt;Thank You!&lt;/P&gt;

&lt;P&gt;Summary Index Data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;141&amp;gt;Apr 21 18:25:41 ff-sslvpn-1 tvv[3645]: 01490500:5: 7a35ba21: **New session** from client IP 255.255.255.0
&amp;lt;141&amp;gt;Apr 21 18:25:43 ff-sslvpn-1 axx[3594]: 01490116:5: 7a35ba21: User chose option: 0
&amp;lt;141&amp;gt;Apr 21 18:25:46 ff-sslvpn-1 axx[3594]: 01490116:5: 7a35ba21: User chose option: 1
&amp;lt;141&amp;gt;Apr 21 18:26:22 ff-sslvpn-1 axx[3594]: 01490010:5: 7a35ba21: Username 'Altavista'
&amp;lt;141&amp;gt;Apr 21 18:26:22 ff-sslvpn-1 axx[3594]: 01490115:5: 7z15ba21: Following rule 'G-S-
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490008:5: 7z15ba21: Connectivity resource '/LIVER
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490128:5: 7z15ba21: Webtop '/LIVER/WT_
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490115:5: 7z15ba21: Following rule 'fallback' 
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490115:5: 7z15ba21: Following rule 'Out' 
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490005:5: 7z15ba21: Following rule 'Out' from item '
&amp;lt;141&amp;gt;Apr 21 18:26:26 ff-sslvpn-1 axx[3594]: 01490102:5: 7z15ba21: Access policy result: Network_Access
&amp;lt;141&amp;gt;Apr 21 18:26:31 ff-sslvpn-1 tvv2[3645]: 01490549:5: 7z15ba21: Assigned PPP Dynamic I
&amp;lt;141&amp;gt;Apr 21 18:26:31 ff-sslvpn-1 tvv2[3645]: 01490505:5: 7z15ba21: PPP tunnel 0x5700f3c9a900 started.
&amp;lt;141&amp;gt;Apr 21 18:26:40 ff-sslvpn-1 tvv[3645]: 01490501:5: 7z15ba21: **Session deleted** due to user logout request.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;summary_index=vendor-traffic-grp1&lt;BR /&gt;
Session start = New Session&lt;BR /&gt;
Session end = Session deleted&lt;BR /&gt;
session_id = 7z15ba21&lt;BR /&gt;
Table/panel/dashboard will be: username, session_id, duration&lt;BR /&gt;
** i'll figure out how to visually show active vs closed connections&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:33:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225062#M66352</guid>
      <dc:creator>rewritex</dc:creator>
      <dc:date>2020-09-29T09:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of a session to populate a summary index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225063#M66353</link>
      <description>&lt;P&gt;Instead of the transaction command (slow) you could try this approach to get the desired results. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex "\*\*(?&amp;lt;state&amp;gt;.*)\*\*" | rex "Username\s'(?&amp;lt;user&amp;gt;\w+)'" | rex "(?&amp;lt;session&amp;gt;7\w+1)" | stats earliest(eval(if(state=="New session", _time, null()))) as start earliest(eval(if(state=="Session deleted", _time, null()))) as end first(user) as user by session | eval duration=tostring(start-end, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 20:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225063#M66353</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-27T20:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of a session to populate a summary index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225064#M66354</link>
      <description>&lt;P&gt;First of all, you forgot the pipe ( &lt;CODE&gt;|&lt;/CODE&gt; ) before the &lt;CODE&gt;transaction&lt;/CODE&gt; command so that may be part of the problem; in any case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test1 | stats earliest(_time) AS earliest latest(_time) AS latest BY vendor_session_id | eval duration = tostring((latest-earliest), "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2016 19:38:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225064#M66354</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-28T19:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of a session to populate a summary index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225065#M66355</link>
      <description>&lt;P&gt;Concerning the pipe, it was a copy/paste error .. thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:45:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225065#M66355</guid>
      <dc:creator>rewritex</dc:creator>
      <dc:date>2016-05-02T16:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of a session to populate a summary index?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225066#M66356</link>
      <description>&lt;P&gt;It seems I may be approaching my task incorrectly... The general consensus is to use STATS and work without the summary index ... I appreciate your responses and I am going to close down this question.&lt;/P&gt;

&lt;P&gt;My problems seem to stem from the combination of using a transaction command and an index summary.&lt;BR /&gt;
If I continue this route, and find a solution.... i'll add comments to my previous questions.&lt;/P&gt;

&lt;P&gt;Thank You.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-a-session-to-populate-a-summary/m-p/225066#M66356</guid>
      <dc:creator>rewritex</dc:creator>
      <dc:date>2016-05-02T16:50:59Z</dc:date>
    </item>
  </channel>
</rss>

