<?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 Calculate time difference, then calculate average duration per severity level in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-then-calculate-average-duration-per/m-p/91669#M23636</link>
    <description>&lt;P&gt;This is a sample snippet from a very large log file:&lt;/P&gt;

&lt;P&gt;lastOccurrence=2012/07/05 13:56:14|firstOccurrence=2012/06/18 13:46:12|severity=1|ticketNumber=111&lt;BR /&gt;
lastOccurrence=2012/07/05 14:56:09|firstOccurrence=2012/06/18 14:45:59|severity=1|ticketNumber=111&lt;BR /&gt;
lastOccurrence=2012/07/05 15:56:09|firstOccurrence=2012/06/18 15:45:59|severity=3|ticketNumber=222&lt;BR /&gt;
lastOccurrence=2012/07/05 16:56:09|firstOccurrence=2012/06/18 16:45:59|severity=3|ticketNumber=222&lt;/P&gt;

&lt;P&gt;Each ticket (number) can have many (sometimes in the 100's) updates for each ticket in the logs.&lt;/P&gt;

&lt;P&gt;My question is how can I find the average ticket duration for each severity level (levels 1-5).&lt;/P&gt;

&lt;P&gt;So how to calculate the time difference between the last and first occurrence of each ticket?  Then how to get the average of all severity level times?  Can Splunk do that?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jul 2012 15:41:18 GMT</pubDate>
    <dc:creator>DTERM</dc:creator>
    <dc:date>2012-07-05T15:41:18Z</dc:date>
    <item>
      <title>Calculate time difference, then calculate average duration per severity level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-then-calculate-average-duration-per/m-p/91669#M23636</link>
      <description>&lt;P&gt;This is a sample snippet from a very large log file:&lt;/P&gt;

&lt;P&gt;lastOccurrence=2012/07/05 13:56:14|firstOccurrence=2012/06/18 13:46:12|severity=1|ticketNumber=111&lt;BR /&gt;
lastOccurrence=2012/07/05 14:56:09|firstOccurrence=2012/06/18 14:45:59|severity=1|ticketNumber=111&lt;BR /&gt;
lastOccurrence=2012/07/05 15:56:09|firstOccurrence=2012/06/18 15:45:59|severity=3|ticketNumber=222&lt;BR /&gt;
lastOccurrence=2012/07/05 16:56:09|firstOccurrence=2012/06/18 16:45:59|severity=3|ticketNumber=222&lt;/P&gt;

&lt;P&gt;Each ticket (number) can have many (sometimes in the 100's) updates for each ticket in the logs.&lt;/P&gt;

&lt;P&gt;My question is how can I find the average ticket duration for each severity level (levels 1-5).&lt;/P&gt;

&lt;P&gt;So how to calculate the time difference between the last and first occurrence of each ticket?  Then how to get the average of all severity level times?  Can Splunk do that?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2012 15:41:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-then-calculate-average-duration-per/m-p/91669#M23636</guid>
      <dc:creator>DTERM</dc:creator>
      <dc:date>2012-07-05T15:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate time difference, then calculate average duration per severity level</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-then-calculate-average-duration-per/m-p/91670#M23637</link>
      <description>&lt;P&gt;Something like this will do the trick where you use strptime() to convert to epoch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype | eval firstOccurrence=strptime(firstOccurrence,"%Y/%m/%d %H:%M:%S") | eval lastOccurrence=strptime(lastOccurrence,"%Y/%m/%d %H:%M:%S") | stats min(firstOccurrence) as firstOccurrence, max(lastOccurrence) as lastOccurrence by ticketNumber   | eval diff=lastOccurrence-firstOccurrence | stats avg(diff) by severity
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jul 2012 16:11:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-time-difference-then-calculate-average-duration-per/m-p/91670#M23637</guid>
      <dc:creator>ayme</dc:creator>
      <dc:date>2012-07-05T16:11:24Z</dc:date>
    </item>
  </channel>
</rss>

