<?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: Calculate time difference between events for distinct users in transaction log in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299773#M90298</link>
    <description>&lt;P&gt;There are a handful of ways.  In addition to jeffland's answer above, you could also...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction maxspan=1m User | search duration&amp;gt;X
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will group events with the same User (and not separated by more than 1 minute - adjust that) into a "set" of events.  You then have a duration, eventcount, and other information.&lt;/P&gt;

&lt;P&gt;More performance (especially in a distributed environment) can be had by converting that to a stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats max(_time) as Latest min(_time) as Earliest BY User | eval duration=Latest-Earliest | search duration&amp;gt;X
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll like need a bit more &lt;CODE&gt;list(fieldname)&lt;/CODE&gt; or 'values(fieldname)` in the stats command to get all your information out, but know it's possible.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Links to docs on &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Stats"&gt;stats&lt;/A&gt; and the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/CommonStatsFunctions"&gt;functions stats supports&lt;/A&gt;, and finally &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Transaction"&gt;transaction&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2017 12:53:17 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2017-08-24T12:53:17Z</dc:date>
    <item>
      <title>Calculate time difference between events for distinct users in transaction log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299771#M90296</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;We are hitting a wall here... we would like to show events where a user does more than &lt;EM&gt;x&lt;/EM&gt; actions within a small time window (1-3 seconds). &lt;/P&gt;

&lt;P&gt;The log looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;24.08.17;10:13:13|WebContainer : 36|DEBUG|User1|d.s.s.c.BaseController|SomeController.java:2269 - MyHandler: 561170, MyStep: 1801513, Action: ENVP, Timestamp: 2017-08-24-10.13.13.0018
24.08.17;10:13:14|WebContainer : 36|DEBUG|User1|d.s.s.c.BaseController|SomeController.java:2269 - MyHandler: 561170, MyStep: 1801513, Action: ENVP, Timestamp: 2017-08-24-10.13.13.0019
24.08.17;10:12:59|WebContainer : 37|DEBUG|User2|d.s.s.c.BaseController|SomeController.java:2269 - MyHandler: 561170, MyStep: 1801513, Action: SAVE, Timestamp: 2017-08-24-10.12.59.0595
24.08.17;10:12:55|WebContainer : 5|DEBUG|User2|d.s.s.c.BaseController|SomeController.java:2269 - MyHandler: 561170, MyStep: 1801513, Action: ENVP, Timestamp: 2017-08-24-10.12.55.0820
24.08.17;10:12:41|WebContainer : 0|DEBUG|A010999|d.s.s.c.BaseController|SomeController.java:2269 - MyHandler: 561170, MyStep: 1801513, Action: ENVP, Timestamp: 2017-08-24-10.12.40.0992
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;we want to filter out the events where the delta between those events are more that x seconds... for the distinct user. Like above: only user1 has events within 1 seconds.&lt;/P&gt;

&lt;P&gt;What we need now is something like:&lt;BR /&gt;
User:          EventCount     relativetimdeltabetweenevents (might not be needed because its a filter condition)&lt;BR /&gt;
User1                   2                             1 secs&lt;/P&gt;

&lt;P&gt;how can we do this?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 10:20:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299771#M90296</guid>
      <dc:creator>hgehrts_splunk</dc:creator>
      <dc:date>2017-08-24T10:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between events for distinct users in transaction log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299772#M90297</link>
      <description>&lt;P&gt;&lt;CODE&gt;streamstats&lt;/CODE&gt; has a &lt;CODE&gt;time_window&lt;/CODE&gt; attribute. With that, you have a sliding time window and can do a count by user and action (if that is what you need, otherwise you can just do a count by user). &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats"&gt;Docs here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 12:41:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299772#M90297</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2017-08-24T12:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference between events for distinct users in transaction log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299773#M90298</link>
      <description>&lt;P&gt;There are a handful of ways.  In addition to jeffland's answer above, you could also...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction maxspan=1m User | search duration&amp;gt;X
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will group events with the same User (and not separated by more than 1 minute - adjust that) into a "set" of events.  You then have a duration, eventcount, and other information.&lt;/P&gt;

&lt;P&gt;More performance (especially in a distributed environment) can be had by converting that to a stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats max(_time) as Latest min(_time) as Earliest BY User | eval duration=Latest-Earliest | search duration&amp;gt;X
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll like need a bit more &lt;CODE&gt;list(fieldname)&lt;/CODE&gt; or 'values(fieldname)` in the stats command to get all your information out, but know it's possible.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Links to docs on &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Stats"&gt;stats&lt;/A&gt; and the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/CommonStatsFunctions"&gt;functions stats supports&lt;/A&gt;, and finally &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.2/SearchReference/Transaction"&gt;transaction&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 12:53:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-between-events-for-distinct-users-in/m-p/299773#M90298</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2017-08-24T12:53:17Z</dc:date>
    </item>
  </channel>
</rss>

