<?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: Single value return N/A instead of 0 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66683#M16610</link>
    <description>&lt;P&gt;I see.  I'll update my answer.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jun 2012 18:14:16 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2012-06-19T18:14:16Z</dc:date>
    <item>
      <title>Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66678#M16605</link>
      <description>&lt;P&gt;Hi. I have two field Single Value.&lt;BR /&gt;
First is using search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/var/log/online-alerts_splunk2.log" online_aname="*die*" AND NOT online_aname="*blog*error*died*" AND online_avalue&amp;gt;0| stats count by online_ahostname,online_aname,online_avalue | table online_ahostname online_aname  online_avalue | dedup online_ahostname online_aname  | stats count as lista  | rangemap field=lista low=0-0 default=severe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second is using search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mail watchdog | rex field=_raw "From = \"watchdog@(?&amp;lt;watch&amp;gt;.*) " | stats count by watch | stats max(count) as lista | rangemap field=lista low=0-4 default=severe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First search when not find any result display "0" in the SingleValue field. Second search when not find any &lt;STRONG&gt;result display "N/A"&lt;/STRONG&gt;. Could you help me to fix it? I need value "0" in second search too.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jun 2012 17:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66678#M16605</guid>
      <dc:creator>bckq</dc:creator>
      <dc:date>2012-06-03T17:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66679#M16606</link>
      <description>&lt;P&gt;SingleValue has a number of odd corner cases where it displays "N/A" when 0 would be better.   For instance if you're using postprocess, but the base search has 0 rows, it'll say "N/A". And that's even if the postprocess is something like "stats count", where it should thus say "0". &lt;/P&gt;

&lt;P&gt;I think what's happening here, is that there are no values of &lt;CODE&gt;watch&lt;/CODE&gt; defined, so &lt;CODE&gt;stats count by watch&lt;/CODE&gt; is an empty result set.   You can sort of repair this by having &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=mail watchdog | rex field=_raw "From = \"watchdog@(?&amp;lt;watch&amp;gt;.*) " | fillnull watch value="no_watch_value" | stats count by watch | stats max(count) as lista | eval count=if(watch=="no_watch_value",0,count) | rangemap field=lista low=0-4 default=severe&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This would mean that in the case where the 'watchless events' are the only events there, at least a 0 will make it through the whole search pipeline. &lt;/P&gt;

&lt;P&gt;---UPDATE ------&lt;/P&gt;

&lt;P&gt;Here is an updated search that should work even when you have no events at all matched in the initial search.   I apologize but I assumed in my initial answer that you did have events returned consistently for 'index=mail watchdog', but that there was not always a 'watch' value extracted. &lt;/P&gt;

&lt;P&gt;Anyway,  here is the more robust form of the same idea.  This search is resilient to the case when it matches no events at all.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=mail watchdog | rex field=_raw "From = \"watchdog@(?&amp;lt;watch&amp;gt;.*) " | fillnull watch value="no_watch_value" | stats count by watch | stats count max(count) as lista | fillnull lista value="0" | eval count=if(watch=="no_watch_value",0,count) | rangemap field=lista low=0-4 default=severe&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jun 2012 03:51:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66679#M16606</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-06-04T03:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66680#M16607</link>
      <description>&lt;P&gt;Thanks for your reply. Unfortunately after replacing search by your code nothing has changed. Any other ideas? :&amp;lt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2012 10:31:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66680#M16607</guid>
      <dc:creator>bckq</dc:creator>
      <dc:date>2012-06-07T10:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66681#M16608</link>
      <description>&lt;P&gt;If you test the searches by running them in flashtimeline, do they generate a result row? One way or another SingleValue prints "N/A" either when there are zero results, or if there's been an error or search exception along the way.  Make sure you have a Message module so that search exceptions are displayed, and test the search manually to make sure it's returning a row.  I may well have had a typo in there.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2012 16:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66681#M16608</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-06-07T16:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66682#M16609</link>
      <description>&lt;P&gt;In flashtimeline I get message "No results found. Inspect ..." when there are not any alerts. Code that you pasted return correct values if there are any. So it looks like "fillnull" is not working as we want. I don't understand what do you mean "Message module". Where can I find it? Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2012 15:11:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66682#M16609</guid>
      <dc:creator>bckq</dc:creator>
      <dc:date>2012-06-19T15:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66683#M16610</link>
      <description>&lt;P&gt;I see.  I'll update my answer.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2012 18:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66683#M16610</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-06-19T18:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Single value return N/A instead of 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66684#M16611</link>
      <description>&lt;P&gt;Your update works for me. Thank you very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2012 18:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Single-value-return-N-A-instead-of-0/m-p/66684#M16611</guid>
      <dc:creator>bckq</dc:creator>
      <dc:date>2012-08-06T18:01:25Z</dc:date>
    </item>
  </channel>
</rss>

