<?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 calculate the average number of events with errors by field name? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144309#M40155</link>
    <description>&lt;P&gt;Can you point out the mistake in my query and the thought process that went when writing yours.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Sep 2014 18:34:56 GMT</pubDate>
    <dc:creator>vspreethi17</dc:creator>
    <dc:date>2014-09-29T18:34:56Z</dc:date>
    <item>
      <title>How to calculate the average number of events with errors by field name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144307#M40153</link>
      <description>&lt;P&gt;I am trying to calculate the average number of errors by calculating events(with error)/total events. &lt;BR /&gt;
Here is my query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| stats count(_raw) as Total| appendcols[search .... error|rex "(?i)^[^\\.]*\\.\\w+:\\s+(?P.+)"|stats count as errors by FIELDNAME ]|eval average = errors/Total|sort -errors
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELDNAME  | errors |   Total|  average
================================
abc           10 
def            2
ghi            2        30        0.0666
jkl            1
mno            1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected Result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELDNAME   errors    Total  average
================================
abc            10       30      3.3          
def             2       30      0.66
ghi             2       30      0.0666
jkl             1       30      0.33
mno             1       30      0.33
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;my question is why total is not calculated for all the events? what logic I am missing here. &lt;/P&gt;

&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 16:09:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144307#M40153</guid>
      <dc:creator>vspreethi17</dc:creator>
      <dc:date>2014-09-29T16:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average number of events with errors by field name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144308#M40154</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; .... error|rex "(?i)^[^\\.]*\\.\\w+:\\s+(?P.+)"|stats count AS errors by FIELDNAME | join [  ...| stats count(_raw) as Total ] | eval average = errors/Total|sort -errors
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: joins are expensive. &lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 18:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144308#M40154</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2014-09-29T18:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average number of events with errors by field name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144309#M40155</link>
      <description>&lt;P&gt;Can you point out the mistake in my query and the thought process that went when writing yours.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 18:34:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144309#M40155</guid>
      <dc:creator>vspreethi17</dc:creator>
      <dc:date>2014-09-29T18:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average number of events with errors by field name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144310#M40156</link>
      <description>&lt;P&gt;I just went by your requirement. &lt;/P&gt;

&lt;P&gt;Just read up the documentation about appendcols and join. Specifically, appendcols synopsis states that it "Appends the fields of the subsearch results to current results, first results to first result, second to second, etc." In your case, the subsearch returns just one event (the total stats count), and that is why it was getting appended to only one event from your main search. In case of join, all events are combined based on common field (if none specified)... &lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 18:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144310#M40156</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2014-09-29T18:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average number of events with errors by field name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144311#M40157</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2014 18:57:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-number-of-events-with-errors-by/m-p/144311#M40157</guid>
      <dc:creator>vspreethi17</dc:creator>
      <dc:date>2014-09-29T18:57:45Z</dc:date>
    </item>
  </channel>
</rss>

