<?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 from two fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524241#M147893</link>
    <description>&lt;P&gt;Thank you, for your answer. But, this would return the number of times the base search was found by host:&lt;/P&gt;&lt;PRE&gt;| stats count(processTime) by host &lt;/PRE&gt;&lt;P&gt;but thats not what is expected. I have updated the question to reflect the initial log.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 14:59:56 GMT</pubDate>
    <dc:creator>BornConfused</dc:creator>
    <dc:date>2020-10-12T14:59:56Z</dc:date>
    <item>
      <title>Calculate average from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524142#M147877</link>
      <description>&lt;P&gt;My initial log looks something like:&lt;/P&gt;&lt;P&gt;The quick brown&amp;nbsp;fox jumps over&amp;nbsp;the&amp;nbsp;lazy dog, and it jumped in 23092 seconds.&lt;/P&gt;&lt;P&gt;Trying to extract the number value and get an average. I have a query which extracts the 14th value, essentially a time field. This query works, but I am trying to get an average of the times per host.&lt;/P&gt;&lt;P&gt;| rex field=_raw "(\S+\s+){13}(?&amp;lt;processTime&amp;gt;\S+)\s"&lt;BR /&gt;| stats count by processTime, host&lt;/P&gt;&lt;P&gt;processTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; host&lt;BR /&gt;23092&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host123&lt;BR /&gt;45098&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host088&lt;BR /&gt;98987&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host238&lt;BR /&gt;23092&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host123&lt;BR /&gt;23092&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host123&lt;BR /&gt;98656&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host088&lt;BR /&gt;54545&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;host238&lt;/P&gt;&lt;P&gt;I need an average for host123, host088, host238&lt;/P&gt;&lt;P&gt;The above query is also grouping the same times and displaying the counts, which is not preferred.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 14:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524142#M147877</guid>
      <dc:creator>BornConfused</dc:creator>
      <dc:date>2020-10-12T14:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524151#M147878</link>
      <description>&lt;P&gt;Please check this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search query| stats count(processTime) by host 
| stats avg(count) as AvgProcessTime by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 05:17:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524151#M147878</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-10-12T05:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524241#M147893</link>
      <description>&lt;P&gt;Thank you, for your answer. But, this would return the number of times the base search was found by host:&lt;/P&gt;&lt;PRE&gt;| stats count(processTime) by host &lt;/PRE&gt;&lt;P&gt;but thats not what is expected. I have updated the question to reflect the initial log.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 14:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524241#M147893</guid>
      <dc:creator>BornConfused</dc:creator>
      <dc:date>2020-10-12T14:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524244#M147895</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227436"&gt;@BornConfused&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;If I understood your requirement correct, it should be as simple as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  stats avg(processTime) by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;When I add the sample table you provided as input, the given command puts out the average processing time per host:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;host	avg(processTime)
host088	71877
host123	23092
host238	76766&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 15:14:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524244#M147895</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-10-12T15:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate average from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524247#M147896</link>
      <description>&lt;P&gt;Thank you ! This worked like a charm, I didn't think it was this easy.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 15:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-average-from-two-fields/m-p/524247#M147896</guid>
      <dc:creator>BornConfused</dc:creator>
      <dc:date>2020-10-12T15:21:23Z</dc:date>
    </item>
  </channel>
</rss>

