<?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: how to get average of time field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136908#M37461</link>
    <description>&lt;P&gt;Yes I have! Thank you, the last question about this, trying if you can help me with this last step &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The output is 00:15:04.502712, is there some way that I can remove the ms and show it as 00:15:04 ?&lt;/P&gt;

&lt;P&gt;Thank you a lot! &lt;/P&gt;</description>
    <pubDate>Wed, 13 Jan 2016 13:31:30 GMT</pubDate>
    <dc:creator>marina_rovira</dc:creator>
    <dc:date>2016-01-13T13:31:30Z</dc:date>
    <item>
      <title>how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136902#M37455</link>
      <description>&lt;P&gt;I have following values in a field(CPU)&lt;/P&gt;

&lt;P&gt;000 00:00:00.00&lt;/P&gt;

&lt;P&gt;000 00:00:00.03&lt;/P&gt;

&lt;P&gt;000 00:00:43.18&lt;/P&gt;

&lt;P&gt;000 00:00:20.69&lt;/P&gt;

&lt;P&gt;000 00:00:00.04&lt;/P&gt;

&lt;P&gt;000 00:00:00.01&lt;/P&gt;

&lt;P&gt;000 00:00:00.03&lt;/P&gt;

&lt;P&gt;I tried the following query to extract&lt;/P&gt;

&lt;P&gt;...|  eval t = strftime(strptime(CPU,"+%Q %H:%M:%S.%N"),"%H:%M:%S.%N") | stats avg(t) by host&lt;/P&gt;

&lt;P&gt;But unable to get the results&lt;/P&gt;

&lt;P&gt;And suggestions?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;Asif J.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2014 09:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136902#M37455</guid>
      <dc:creator>asifhj</dc:creator>
      <dc:date>2014-04-21T09:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136903#M37456</link>
      <description>&lt;P&gt;Are those values timestamps or durations?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2014 09:35:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136903#M37456</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-21T09:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136904#M37457</link>
      <description>&lt;P&gt;Durations?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2014 10:23:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136904#M37457</guid>
      <dc:creator>asifhj</dc:creator>
      <dc:date>2014-04-21T10:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136905#M37458</link>
      <description>&lt;P&gt;You can do this to convert your duration strings into seconds:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval tmp = replace(replace(duration, "\.\d+$", ""), "\s+", "+") | convert dur2sec(tmp) as converted | fields - tmp | eval converted = converted + tonumber("0.".replace(duration, "^.*\.", ""))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There's a bit of format changing required before &lt;CODE&gt;convert dur2sec()&lt;/CODE&gt; will accept the string, but it'll work. Once you have the durations in seconds you can do any calculation you want, including &lt;CODE&gt;stats avg(converted)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2014 11:16:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136905#M37458</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-21T11:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136906#M37459</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;

&lt;P&gt;I have the same question, but I didn't get your answer. What should be the value of tmp?&lt;BR /&gt;
I don't understand either the tonumber function.&lt;/P&gt;

&lt;P&gt;These are some of the durations I have, the field is called "Time spent" and I would like to calculate the average for a specific search like for especific customer that I've selected before (search customer=X).&lt;BR /&gt;
00:01:00&lt;BR /&gt;
00:02:00&lt;BR /&gt;
00:05:00 &lt;BR /&gt;
00:03:00&lt;BR /&gt;
00:04:00&lt;BR /&gt;
00:06:00&lt;BR /&gt;
00:00:00&lt;BR /&gt;
00:07:00&lt;BR /&gt;
(this is how I search for a specific value for this field Tspent="00:01:00", I supouse it is duration)&lt;/P&gt;

&lt;P&gt;Thanks! &lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 09:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136906#M37459</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2016-01-13T09:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136907#M37460</link>
      <description>&lt;P&gt;You should get the expected result with this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval dur = replace(Tspent, "\.\d+$", "") | convert dur2sec(dur) | stats avg(dur) as avgTspent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jan 2016 13:04:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136907#M37460</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-01-13T13:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to get average of time field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136908#M37461</link>
      <description>&lt;P&gt;Yes I have! Thank you, the last question about this, trying if you can help me with this last step &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The output is 00:15:04.502712, is there some way that I can remove the ms and show it as 00:15:04 ?&lt;/P&gt;

&lt;P&gt;Thank you a lot! &lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 13:31:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-get-average-of-time-field/m-p/136908#M37461</guid>
      <dc:creator>marina_rovira</dc:creator>
      <dc:date>2016-01-13T13:31:30Z</dc:date>
    </item>
  </channel>
</rss>

