<?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 average operation time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360542#M106575</link>
    <description>&lt;P&gt;And what should I do when you say:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename COMMENT as "right here you should also eliminate any records closed in prior weeks" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Aug 2017 03:12:36 GMT</pubDate>
    <dc:creator>pranaynanda</dc:creator>
    <dc:date>2017-08-11T03:12:36Z</dc:date>
    <item>
      <title>Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360538#M106571</link>
      <description>&lt;P&gt;The gut who was doing this job before me made some servicenow reports using excel . He devised a term something that he says "Average process time" and I wish to calculate that. Average process time is said to be &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The average process time is calculated by dividing the Total process time in a week by the respective amount of closed tickets in the same week. The total process time for each ticket in one week is calculated by subtracting the date of creating the ticket in tab Incidents column A from the date of resolving  the ticket in tab Incidents column T. The amount of closed tickets is calculated by counting all tickets which have a resolved date in tab Incidents column T&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I almost have what I need except for the count of tickets in the week. &lt;/P&gt;

&lt;P&gt;this is what I have right now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=comos sourcetype=comos |where State in ("Closed","Resolved")|convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Created) mktime(Resolved) | eval tt=(Resolved-Created)|stats count(State="Resolved") as res|eval xx=(tt/res)|timechart xx span=1w
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Aug 2017 14:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360538#M106571</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-09T14:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360539#M106572</link>
      <description>&lt;P&gt;1) Your &lt;CODE&gt;stats&lt;/CODE&gt; command kills all fields it does not reference. &lt;/P&gt;

&lt;P&gt;2) You don't really need to count the resolved records independently, because that will be all the records that have a duration.  In fact, you probably already killed all the other records by filtering on the state, unless there is an occasional resolved record with no resolution date... which would be a bug in the source process.  &lt;/P&gt;

&lt;P&gt;3) If you want to calculate this across a number of weeks, then you need to include the resolve date as _time and bin it, then use it in &lt;CODE&gt;stats&lt;/CODE&gt; or timechart.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=comos sourcetype=comos 
| where State in ("Closed","Resolved")
| convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Created) mktime(Resolved) 
| eval tt=(Resolved-Created)
| eval _time = relative_time(Resolved,"@w") 
| stats count as "Resolved and Closed Tickets" avg(tt) as "Average Process Time" by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or replace the last two lines with... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1w count as "Resolved and Closed Tickets", avg(tt) as "Average Process Time" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In general, I prefer to &lt;CODE&gt;bin&lt;/CODE&gt; and calculate things myself, but YMMV.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 16:25:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360539#M106572</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-09T16:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360540#M106573</link>
      <description>&lt;P&gt;I like what it gives me but how can I divide both the values as I get? Basically I want to derive what's there in the definition of the calculation.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 15:47:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360540#M106573</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-10T15:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360541#M106574</link>
      <description>&lt;P&gt;@pranaynanda - you were requested to calculate the average duration.  &lt;CODE&gt;avg(tt)&lt;/CODE&gt; is the average duration.  The system has already divided the sum of process time by the number of process items.&lt;/P&gt;

&lt;P&gt;You may want to divide it by either 3600 to get hours, or 86400 to get days.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval  "Average Process Time (Days)" = round( "Average Process Time" /86400,2)
| fields - "Average Process Time" 

| eval  "Average Process Time (Hours) " = round( "Average Process Time" /3600,2)
| fields - "Average Process Time" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 16:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360541#M106574</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-10T16:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360542#M106575</link>
      <description>&lt;P&gt;And what should I do when you say:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename COMMENT as "right here you should also eliminate any records closed in prior weeks" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 03:12:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360542#M106575</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-11T03:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360543#M106576</link>
      <description>&lt;P&gt;@pranaynanda - Wow, that's an OLD version, probably the first one that I posted.  The current code, that has this line... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval _time = relative_time(Resolved,"@w")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... will handle multiple weeks without having to omit any.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:27:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360543#M106576</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-11T14:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360544#M106577</link>
      <description>&lt;P&gt;Can you also help with this last query? I have what I need. I only wish to hide the computer field xx from the Visualization.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=comos sourcetype=comos 
 | where State in ("Closed","Resolved")
 | rename COMMENT as "right here you should also eliminate any records closed in prior weeks" 
 | rename "Resolving Time" as rt
 | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Created) mktime(Resolved) 
 | eval tt=(Resolved-Created)
 | eval _time = relative_time(Resolved,"@w")
 | timechart span=1w count as yy sum(rt) as xx 
 |eval zz= xx/yy
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 11:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360544#M106577</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-14T11:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360545#M106578</link>
      <description>&lt;P&gt;Sorted. Got it. I did this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=comos sourcetype=comos 
 | where State in ("Closed","Resolved")
 | rename "Resolving Time" as rt
 | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Resolved) 
 | eval _time = relative_time(Resolved,"@w")
 |timechart span=1w count as "Number of Tickets" eval(round(avg(rt),2)) as "Average Operational Time"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wish I could convert it to an answer.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Converted it for you and removed the old comment from the code, since it is no longer true.&lt;/P&gt;

&lt;P&gt;Thanks for posting your final working code!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 13:15:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360545#M106578</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-14T13:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360546#M106579</link>
      <description>&lt;P&gt;One little addon that I wanted to do was to have the timechart but display the week numbers instead of dates.&lt;/P&gt;

&lt;P&gt;I did this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=comos sourcetype=comos 
 | where State in ("Closed","Resolved")
 | rename "Resolving Time" as rt 
 | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Resolved)
 | eval _time=relative_time(Resolved,"@w")
 |eval  weeknumber=strftime(Resolved,"%U %Y")
 |timechart span=1w count as "Number of Tickets" eval(round(avg(rt),2)) as "Average Operational Time"  by weeknumber
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but somehow the data is sorted as string and the sorting is all messed up.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 07:29:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360546#M106579</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-16T07:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average operation time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360547#M106580</link>
      <description>&lt;P&gt;Okay, so I finally got what I wanted but now I want to use a time modifier and I can't wrap my head around those concepts. The date that it selects in the last value is from Thursday to Thursday. Instead I want it Monday to Monday. Please help:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=comos sourcetype=comos 
 | where State in ("Closed","Resolved")
 | rename "Resolving Time" as rt 
 | convert timeformat="%Y-%m-%d %H:%M:%S" mktime(Resolved)
 | eval _time = relative_time(Resolved,"@w")
 |timechart span=1w count as "Number of Tickets" eval(round(avg(rt),2)) as "Average Operational Time" 
 |eval Time=strftime(_time, "%U %Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 10:01:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-operation-time/m-p/360547#M106580</guid>
      <dc:creator>pranaynanda</dc:creator>
      <dc:date>2017-08-18T10:01:13Z</dc:date>
    </item>
  </channel>
</rss>

