<?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: stats sum(duration) by user date_month date_year - Not really Addition of duration? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53646#M13039</link>
    <description>&lt;P&gt;You can explicitly compute the equivalent of date_mday using eval: "... | eval mday = strftime(_time, "%m")"&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 09:17:54 GMT</pubDate>
    <dc:creator>Stephen_Sorkin</dc:creator>
    <dc:date>2020-09-28T09:17:54Z</dc:date>
    <item>
      <title>stats sum(duration) by user date_month date_year - Not really Addition of duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53643#M13036</link>
      <description>&lt;P&gt;Splunkers...
I am looking at a VPN logs from a Cisco ASA and trying to calculate the amount of time per day per user that a user spends logged into the VPN.  I can run the following and the output looks right:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;asa_logid="%ASA-6-602303" OR asa_logid="%ASA-6-602304" outbound sourcetype="syslog" earliest=-10d@d latest=+1d@d
| transaction startswith="has been created" endswith="has been deleted" by vpn_session 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I get in output is an event that is started and ended properly by the vpn_session id(an extracted value from the log) but user.  I also get a value called duration (which seems to be the length of the event in seconds).  Thus I figured I could sum the duration by user by date_month like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;asa_logid="%ASA-6-602303" OR asa_logid="%ASA-6-602304" outbound sourcetype="syslog" source="/var/log/hosts/172.30.64.2/messages.log" earliest=-10d@d latest=+1d@d
| transaction startswith="has been created" endswith="has been deleted" by vpn_session
| stats sum(duration) by vpn_user date_month date_year
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However this summation shows people logged into the VPN for hundreds of hours per day... clearly not possible...&lt;/P&gt;

&lt;P&gt;What am I doing wrong here?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2010 08:33:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53643#M13036</guid>
      <dc:creator>starks951</dc:creator>
      <dc:date>2010-09-19T08:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: stats sum(duration) by user date_month date_year - Not really Addition of duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53644#M13037</link>
      <description>&lt;P&gt;Your search syntax looks right, and the stats should calculate the sum of the duration field. You should note that your stats is calculating the total duration for the month, not for the day, so it's not unreasonable for it to be greater than 86,400s.&lt;/P&gt;

&lt;P&gt;Another possibility is that vpn_user has become a multivalued field and certain sessions are counting against multiple users.&lt;/P&gt;

&lt;P&gt;I'd pipe the output of &lt;CODE&gt;transaction&lt;/CODE&gt; to &lt;CODE&gt;stats sum(duration) count&lt;/CODE&gt; to see what the total duration and number of sessions is, as a sanity check.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2010 23:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53644#M13037</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-09-20T23:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: stats sum(duration) by user date_month date_year - Not really Addition of duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53645#M13038</link>
      <description>&lt;P&gt;Ok... so I ran some MORE analysis... and it looks like date_mday is a multi-value field (for those events that last over the break in the day, ie start at 1130pm and end at 0200am).  At which point we are counting this event on BOTH days.. &lt;/P&gt;

&lt;P&gt;Going to have to figure out how to only report that ONCE.&lt;/P&gt;

&lt;P&gt;Thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2010 01:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53645#M13038</guid>
      <dc:creator>starks951</dc:creator>
      <dc:date>2010-09-21T01:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: stats sum(duration) by user date_month date_year - Not really Addition of duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53646#M13039</link>
      <description>&lt;P&gt;You can explicitly compute the equivalent of date_mday using eval: "... | eval mday = strftime(_time, "%m")"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:17:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53646#M13039</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2020-09-28T09:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: stats sum(duration) by user date_month date_year - Not really Addition of duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53647#M13040</link>
      <description>&lt;P&gt;I don't have any issues getting the month day, the problem is that the two events that make up the transaction have two different month days.  How do I get it to evaluation only ONE of them.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2010 00:10:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-sum-duration-by-user-date-month-date-year-Not-really/m-p/53647#M13040</guid>
      <dc:creator>starks951</dc:creator>
      <dc:date>2010-09-24T00:10:12Z</dc:date>
    </item>
  </channel>
</rss>

