<?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: Error when using eval in a range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168132#M47918</link>
    <description>&lt;P&gt;The sum of "nothing" is not zero, it's "nothing" or rather null. To fix that, you could include this before the stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval isFailure=... | append [stats count | eval isFailure=0] | stats sum(isFailure) as failures | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll make sure there always is at least one zero to sum up, guaranteeing a numeric sum.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Oct 2014 11:05:26 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-10-16T11:05:26Z</dc:date>
    <item>
      <title>Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168122#M47908</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
i have the following search query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=project_omega host=PersistUBS | transaction startswith="Targeting file BP_Comp_Summ_Pos*" endswith="Server returned an error: No such file or folder" OR "The file was downloaded successfully." | search "Error" OR "Attempt 3...unsuccessful."  | eval interval=relative_time(_time,"@d") | eval isFailure=if(searchmatch("Error") OR searchmatch("Attempt 3...unsuccessful."),1,0) | stats sum(isFailure) as failures | rangemap field=failures low=0-0 elevated=1-2 severe=3-15 default=15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's showing as N/A instead of a number, please can someone suggest why this is?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 09:57:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168122#M47908</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-15T09:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168123#M47909</link>
      <description>&lt;P&gt;Hi markthompson,&lt;/P&gt;

&lt;P&gt;what will happen if you try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=project_omega host=PersistUBS 
| transaction startswith="Targeting file BP_Comp_Summ_Pos*" endswith="Server returned an error: No such file or folder" OR "The file was downloaded successfully." 
| search "Error" OR "Attempt 3...unsuccessful."  
| eval interval=relative_time(_time,"@d") 
| eval isFailure=if(searchmatch("Error") OR searchmatch("Attempt 3...unsuccessful."),1,0) 
| stats sum(isFailure) as failures 
| eval failuresCategory = case(failures=0,"low",failures&amp;lt;3,"elevated",failures&amp;gt;=3,"severe")
| table failuresCategory 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe this will help you to get to the point.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 11:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168123#M47909</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-15T11:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168124#M47910</link>
      <description>&lt;P&gt;Make sure you set the default range to something other than &lt;CODE&gt;15&lt;/CODE&gt;, probably &lt;CODE&gt;default=critical&lt;/CODE&gt; or something like that.&lt;/P&gt;

&lt;P&gt;Also note you're calculating an &lt;CODE&gt;interval&lt;/CODE&gt; field but not using it.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 20:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168124#M47910</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-15T20:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168125#M47911</link>
      <description>&lt;P&gt;Hi MuS Thanks for this answer.&lt;BR /&gt;
However, I wish to use the rangemap command as it's configured on the dashboard to create a traffic light based on the level (low, elevated or severe)&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 09:38:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168125#M47911</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-16T09:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168126#M47912</link>
      <description>&lt;P&gt;Use eval to compute a field called range using the case suggested by @MuS and you'll have the same behaviour as rangemap, including dashboard visualizations using the field value as a CSS class.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 09:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168126#M47912</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T09:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168127#M47913</link>
      <description>&lt;P&gt;Hey Martin, can you please give me an example of the string you would use and I'll mark it as answer if it works.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 10:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168127#M47913</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-16T10:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168128#M47914</link>
      <description>&lt;P&gt;Basically what @MuS said:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...  | eval range = case(failures=0,"low",failures&amp;lt;3,"elevated",failures&amp;gt;=3,"severe")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Oct 2014 10:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168128#M47914</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T10:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168129#M47915</link>
      <description>&lt;P&gt;I've tried this and then it still says N/A on my dashboard.  &lt;/P&gt;

&lt;P&gt;Current string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=project_omega host=PersistUBS | transaction startswith="Targeting file BP_Comp_Summ_Pos*" endswith="Server returned an error: No such file or folder" OR "The file was downloaded successfully."  | search "Error" OR "Attempt 3...unsuccessful."  
 | eval interval=relative_time(_time,"@d") 
 | eval isFailure=if(searchmatch("Error") OR searchmatch("Attempt 3...unsuccessful."),1,0) 
 | stats sum(isFailure) as failures 
 | eval failuresCategory = case(failures=0,"low",failures&amp;lt;3,"elevated",failures&amp;gt;=3,"severe")
 | eval range = case(failures=0,"low",failures&amp;lt;3,"elevated",failures&amp;gt;=3,"severe")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Oct 2014 10:13:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168129#M47915</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-16T10:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168130#M47916</link>
      <description>&lt;P&gt;Doesn't sound like a rangemap issue, this is the value showing N/A rather than the colour, right?&lt;/P&gt;

&lt;P&gt;Make sure there actually are matching events in the time range to have something to sum up.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 10:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168130#M47916</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T10:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168131#M47917</link>
      <description>&lt;P&gt;There are no events in Today that have failed, so it should default to low (green).  Any ideas why it's not doing so?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168131#M47917</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2014-10-16T11:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168132#M47918</link>
      <description>&lt;P&gt;The sum of "nothing" is not zero, it's "nothing" or rather null. To fix that, you could include this before the stats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval isFailure=... | append [stats count | eval isFailure=0] | stats sum(isFailure) as failures | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That'll make sure there always is at least one zero to sum up, guaranteeing a numeric sum.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168132#M47918</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T11:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168133#M47919</link>
      <description>&lt;P&gt;Just asking: why not a simple &lt;CODE&gt;isnull&lt;/CODE&gt; eval instead of the appended subsearch?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval isFailure=if(isnull(isFailure),"0",isFailure) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:14:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168133#M47919</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-16T11:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168134#M47920</link>
      <description>&lt;P&gt;When there are zero events that eval would be run zero times &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:15:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168134#M47920</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T11:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168135#M47921</link>
      <description>&lt;P&gt;true .. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168135#M47921</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-16T11:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168136#M47922</link>
      <description>&lt;P&gt;btw, just found a way to do this without &lt;CODE&gt;append&lt;/CODE&gt; and it works with or without finding results. If it's okay I'll mail you the search so you can verify this twisted search &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 12:27:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168136#M47922</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-16T12:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168137#M47923</link>
      <description>&lt;P&gt;Post it here and let the world be your critic?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 13:16:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168137#M47923</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-16T13:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using eval in a range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168138#M47924</link>
      <description>&lt;P&gt;Hi markthompson,&lt;/P&gt;

&lt;P&gt;based on @martin_mueller 's answer and my comment, I did some research and tests, how this could be done without use of a sub search. It took a while, but here is what you can try and it should handle the case when there are no events at all during the search time range:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=project_omega host=PersistUBS 
| transaction startswith="Targeting file BP_Comp_Summ_Pos*" endswith="Server returned an error: No such file or folder" OR "The file was downloaded successfully." 
| search "Error" OR "Attempt 3...unsuccessful."  
| eval isFailure=if(searchmatch("Error") OR searchmatch("Attempt 3...unsuccessful."),1,0) 
| stats count AS myCount sum(isFailure) as failures 
| eval failure=if(myCount=="0",0,failure)
| rangemap field=failures low=0-0 elevated=1-2 severe=3-15 default=15
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2014 11:57:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Error-when-using-eval-in-a-range/m-p/168138#M47924</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-17T11:57:17Z</dc:date>
    </item>
  </channel>
</rss>

