<?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: Problem computing error rate from two different queries for a graph. . . in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280601#M84678</link>
    <description>&lt;P&gt;I'm having trouble following the exact problem but some things I see that might be contributing:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;No field name is specified for the join. That could provide unexpected behavior of how data is merged.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bucket _time ... | stats ... | xyseries ....&lt;/CODE&gt; seems awfully similar to using &lt;CODE&gt;timechart&lt;/CODE&gt;. So just wanted to make sure you knew about that command&lt;/LI&gt;
&lt;LI&gt;You might want to round the eval, but not necessarily. Just making sure you knew it was available.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I have a vendetta against &lt;CODE&gt;joins&lt;/CODE&gt;. Would you be able to run both searches at the root search and then simply use an eval in the &lt;CODE&gt;stats&lt;/CODE&gt; command to get both results? You could also use the &lt;CODE&gt;like&lt;/CODE&gt; function of eval instead of the &lt;CODE&gt;_raw="**"&lt;/CODE&gt; like below.&lt;/P&gt;

&lt;P&gt;index=prod_stuff source="xyzzy"&lt;BR /&gt;
 | bucket _time span=1s&lt;BR /&gt;
 | stats count AS totalErrors, count(eval(_raw="&lt;EM&gt;FATAL&lt;/EM&gt;" OR _raw="&lt;EM&gt;ERROR&lt;/EM&gt;" OR _raw="&lt;EM&gt;stringa&lt;/EM&gt;"...)) as totalErrors by _time, host &lt;BR /&gt;
 | eval errorRate = round( totalErrors/totalCount*100 , 2 )&lt;BR /&gt;
 | xyseries _time, host, errorRate&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Tue, 29 Sep 2020 08:44:45 GMT</pubDate>
    <dc:creator>sloshburch</dc:creator>
    <dc:date>2020-09-29T08:44:45Z</dc:date>
    <item>
      <title>Problem computing error rate from two different queries for a graph. . .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280599#M84676</link>
      <description>&lt;P&gt;Other answers I have found don't quite seem to work in my case here.   Have seen similar where it can be done based on say "type=" fields and the append/join suggestions don't quite work either.&lt;/P&gt;

&lt;P&gt;Hoping someone has a simple solution while I continue to hack/dig for the solution myself. . . &lt;/P&gt;

&lt;P&gt;This query LOOKS like what I want as a result. . .   total errors / total counts * 100. . .   the eval for the error rate does not use the correct correlated bucket error count.   It seems to always use the first error count for every bucket percentage. . .    &lt;/P&gt;

&lt;P&gt;every bucket error rate is 12 / (1 second total count) * 100    because 12 seems to be the First 1 second bucket error count.&lt;/P&gt;

&lt;P&gt;each of the join querys works fine by itself to create a nice line/graph. . .&lt;BR /&gt;
index=prod_stuff source="&lt;EM&gt;xyzzy&lt;/EM&gt;" | bucket _time span=1s &lt;BR /&gt;
    | stats count as totalCount by _time, host &lt;BR /&gt;
| join &lt;BR /&gt;
      [search index=prod_stuff source="&lt;EM&gt;xyzzy&lt;/EM&gt;"  ("FATAL" OR "ERROR" OR "stringa" OR . . . ) &lt;BR /&gt;
           NOT ("WARN" OR "string1" OR "string2" OR "string3" OR "string4" OR . . . )&lt;BR /&gt;&lt;BR /&gt;
           | bucket _time span=1s  | stats  count AS totalErrors by _time, host  ] &lt;BR /&gt;
     | eval errorRate=totalErrors/totalCount*100 | xyseries _time, host, errorRate&lt;/P&gt;

&lt;P&gt;This produces a very nice looking graph if I did not care too much about the numbers being correct.&lt;/P&gt;

&lt;P&gt;Don't care if this is done using a join, just most efficient way to do this is what I am looking for.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:44:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280599#M84676</guid>
      <dc:creator>dwfarris</dc:creator>
      <dc:date>2020-09-29T08:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem computing error rate from two different queries for a graph. . .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280600#M84677</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=prod_stuff source="xyzzy" | bucket _time span=1s 
| stats count as totalCount by _time, host | append [ search index=prod_stuff source="xyzzy" ("FATAL" OR "ERROR" OR "stringa" OR . . . ) 
NOT ("WARN" OR "string1" OR "string2" OR "string3" OR "string4" OR . . . ) 
| bucket _time span=1s | stats count AS totalErrors by _time, host ]
| stats values(total*) as total* by _time host  | eval errorRate=totalErrors*100/totalCount
timechart span=1s max(errorRate) by host useother=f
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Feb 2016 21:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280600#M84677</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-12T21:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem computing error rate from two different queries for a graph. . .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280601#M84678</link>
      <description>&lt;P&gt;I'm having trouble following the exact problem but some things I see that might be contributing:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;No field name is specified for the join. That could provide unexpected behavior of how data is merged.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;bucket _time ... | stats ... | xyseries ....&lt;/CODE&gt; seems awfully similar to using &lt;CODE&gt;timechart&lt;/CODE&gt;. So just wanted to make sure you knew about that command&lt;/LI&gt;
&lt;LI&gt;You might want to round the eval, but not necessarily. Just making sure you knew it was available.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I have a vendetta against &lt;CODE&gt;joins&lt;/CODE&gt;. Would you be able to run both searches at the root search and then simply use an eval in the &lt;CODE&gt;stats&lt;/CODE&gt; command to get both results? You could also use the &lt;CODE&gt;like&lt;/CODE&gt; function of eval instead of the &lt;CODE&gt;_raw="**"&lt;/CODE&gt; like below.&lt;/P&gt;

&lt;P&gt;index=prod_stuff source="xyzzy"&lt;BR /&gt;
 | bucket _time span=1s&lt;BR /&gt;
 | stats count AS totalErrors, count(eval(_raw="&lt;EM&gt;FATAL&lt;/EM&gt;" OR _raw="&lt;EM&gt;ERROR&lt;/EM&gt;" OR _raw="&lt;EM&gt;stringa&lt;/EM&gt;"...)) as totalErrors by _time, host &lt;BR /&gt;
 | eval errorRate = round( totalErrors/totalCount*100 , 2 )&lt;BR /&gt;
 | xyseries _time, host, errorRate&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280601#M84678</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2020-09-29T08:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem computing error rate from two different queries for a graph. . .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280602#M84679</link>
      <description>&lt;P&gt;Thanks, &lt;/P&gt;

&lt;P&gt;I used @SloshBurch's and with some mods got it to work.&lt;BR /&gt;&lt;BR /&gt;
(thanks somesoni1, but did not try yours)&lt;/P&gt;

&lt;P&gt;Agree, don't like joins/appends, but that came closest to describe problem of my several initial attempts. . . &lt;/P&gt;

&lt;P&gt;I did have to modify it, so for others that might come across this, I could not use the &lt;CODE&gt;raw="*string*"&lt;/CODE&gt;.   Those wildcards would not work.   &lt;/P&gt;

&lt;P&gt;SAME structure, but had to use &lt;CODE&gt;like&lt;/CODE&gt; instead for string comparison.   &lt;/P&gt;

&lt;P&gt;This search works fine now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=prod_stuff source="good_stuff*"
| bucket _time span=1s 
| stats count as totalCount, count(eval((like(_raw,"%ERROR%") OR like(_raw,"%string1%") OR like(_raw,"%string2%")) AND NOT like(_raw,"%string3%") AND NOT like(_raw,"%string4%") AND NOT like(_raw,"%string5%") AND NOT like(_raw,"%string6%"))) as totalErrors by _time, host 
| eval errorRate=round(totalErrors/totalCount*100,2) 
| xyseries _time,host,errorRate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Feb 2016 21:35:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-computing-error-rate-from-two-different-queries-for-a/m-p/280602#M84679</guid>
      <dc:creator>dwfarris</dc:creator>
      <dc:date>2016-02-19T21:35:42Z</dc:date>
    </item>
  </channel>
</rss>

