<?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: Average of Seconds and Milliseconds using extracted values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538814#M152357</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/55596"&gt;@tjsnow&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I confused the conversion missed the "s" option. I am glad you found right way..&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 18:21:03 GMT</pubDate>
    <dc:creator>scelikok</dc:creator>
    <dc:date>2021-02-05T18:21:03Z</dc:date>
    <item>
      <title>Average of Seconds and Milliseconds using extracted values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538671#M152302</link>
      <description>&lt;P&gt;I am trying to put together and average duration (calculated and logged by product) as well as count. however the logs show an "s" or "ms" at the end of the value to reflect how long processing took. I need to convert the results into an average duration but have been unable to figure it out.&amp;nbsp; In this example is shows ms, but could be seconds on the next records and the value end in s&lt;/P&gt;&lt;P&gt;Example Record:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;request.status='completed'; status.message=''; request.start='2021-01-29 15:50:25.402471006 +0000 UTC m=+501.139572300'; request.end='2021-01-29 15:50:26.193830852 +0000 UTC m=+501.930932145'; request.duration='791.359845ms'" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current query (note requestduration is an extracted field resulting in the value of request.duration as&amp;nbsp;791.359845ms in this case) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count(requestduration) as count avg(requestduration) as Average by source&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get that I cannot average the values with the alpha characters in there, but I don't know how to convert the seconds into milis second then remove the character and average them.. Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 19:28:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538671#M152302</guid>
      <dc:creator>tjsnow</dc:creator>
      <dc:date>2021-02-04T19:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Average of Seconds and Milliseconds using extracted values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538680#M152304</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/55596"&gt;@tjsnow&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try below;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval requestduration=if(match(requestduration,"ms"),tonumber(replace(requestduration,"ms",""))*1000,requestduration) 
| stats count(requestduration) as count avg(requestduration) as Average by source&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Feb 2021 19:53:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538680#M152304</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-02-04T19:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average of Seconds and Milliseconds using extracted values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538794#M152343</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp; &amp;nbsp;Thank you this got me on the right path... There were a couple changes though, so I will post them incase anyone else runs into something similar...&lt;/P&gt;&lt;P&gt;To go from Milliseconds to Seconds we need to divide not multiply, and in this case I still had to strip the S out of the records that were displayed in seconds, because the average wouldn't work if half the records had an alpha character in them. So I added a second if statement with no calculation. Here is the final solution.&amp;nbsp; Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval requestduration=if(match(requestduration,"ms"),tonumber(replace(requestduration,"ms",""))/1000,requestduration) 
| eval requestduration=if(match(requestduration,"s"),tonumber(replace(requestduration,"s","")),requestduration)
| stats count(requestduration) as count avg(requestduration) as "Average Seconds" by source&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Feb 2021 16:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538794#M152343</guid>
      <dc:creator>tjsnow</dc:creator>
      <dc:date>2021-02-05T16:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Average of Seconds and Milliseconds using extracted values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538814#M152357</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/55596"&gt;@tjsnow&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I confused the conversion missed the "s" option. I am glad you found right way..&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 18:21:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-of-Seconds-and-Milliseconds-using-extracted-values/m-p/538814#M152357</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-02-05T18:21:03Z</dc:date>
    </item>
  </channel>
</rss>

