<?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 starting and completing a task in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37958#M6970</link>
    <description>&lt;P&gt;This is exactly what I was looking for!&lt;/P&gt;</description>
    <pubDate>Mon, 13 Oct 2014 16:28:42 GMT</pubDate>
    <dc:creator>Splunkster45</dc:creator>
    <dc:date>2014-10-13T16:28:42Z</dc:date>
    <item>
      <title>calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37952#M6964</link>
      <description>&lt;P&gt;I have a database that stores a separate event every time someone starts or stops a task. This should be a simple task, but I cant seem to figure out how to go about the calculation. There are three things I need to account for: accepting the task, abandoning the task, and completing the task. I only want to calculate the time it takes between each user's accepting a task and completing it. If they abandoned it, then I don't want splunk to calculate the time &lt;BR /&gt;&lt;BR /&gt;
This is working off of timestamps and the fields user_name and action &lt;BR /&gt;&lt;BR /&gt;
action=0 for accepting &lt;BR /&gt;&lt;BR /&gt;
action=1 for completing &lt;BR /&gt;&lt;BR /&gt;
action=2 for abandoning&lt;/P&gt;

&lt;P&gt;Any suggestions as to how I would go about this calculation?&lt;/P&gt;

&lt;P&gt;EDIT: My supervisors loved it, but now they want me to cut out times when the users are not logged in. I asked around, and got a nice addition to the logs: total_login_time, which, as it's so simply named, is a simple record, in milliseconds, of how long the users have been logged in to the site. Can I still use transaction? Or do I need to change it entirely?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:14:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37952#M6964</guid>
      <dc:creator>atreece</dc:creator>
      <dc:date>2020-09-28T10:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37953#M6965</link>
      <description>&lt;P&gt;I would recommend that you take a look at the "transaction" command. It has a built in field called "duration". Here is an example of how to use it. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="your data" | transaction action beginswith="0" endswith="2" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might need to experiment with the maxspan and maxpause as well. &lt;/P&gt;

&lt;P&gt;Here is a link to more information:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.5/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/4.2.5/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2011 14:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37953#M6965</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2011-12-20T14:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37954#M6966</link>
      <description>&lt;P&gt;+1 on using transaction, but using &lt;CODE&gt;action&lt;/CODE&gt; as the correlating field won't work as it is changing within the session. &lt;CODE&gt;user_name&lt;/CODE&gt; seems more appropriate. Also perhaps specify the conditions a bit more so that it's the actual &lt;CODE&gt;action&lt;/CODE&gt; field that is checked for the values 0 and 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction user_name startswith=eval(action=0) endswith=eval(action=2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2011 14:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37954#M6966</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-12-20T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37955#M6967</link>
      <description>&lt;P&gt;Great Stuff Ayn. Thanks. Give the points to Ayn!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2011 15:15:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37955#M6967</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2011-12-20T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37956#M6968</link>
      <description>&lt;P&gt;That's giving me some very nice results!&lt;BR /&gt;
Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2011 15:37:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37956#M6968</guid>
      <dc:creator>atreece</dc:creator>
      <dc:date>2011-12-20T15:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37957#M6969</link>
      <description>&lt;P&gt;Yes, I did have to change it around a bit. The resulting search string looks a bit like this: &lt;/P&gt;

&lt;P&gt;index=task_data task="*" NOT action="2" | transaction user_name startswith="action=0" endswith="action=1" maxevents="2" | where duation&amp;gt;0 | stats count by duration, task_name | fields task_name, duration |sort -duration |rename task_name AS "Task Name"&lt;/P&gt;

&lt;P&gt;and it's giving me fairly nice results.&lt;/P&gt;

&lt;P&gt;on an unrelated note, I love your picture. That game was really fun.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:14:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37957#M6969</guid>
      <dc:creator>atreece</dc:creator>
      <dc:date>2020-09-28T10:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference between starting and completing a task</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37958#M6970</link>
      <description>&lt;P&gt;This is exactly what I was looking for!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2014 16:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/calculate-time-difference-between-starting-and-completing-a-task/m-p/37958#M6970</guid>
      <dc:creator>Splunkster45</dc:creator>
      <dc:date>2014-10-13T16:28:42Z</dc:date>
    </item>
  </channel>
</rss>

