<?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: Table message when No results found. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74250#M18689</link>
    <description>&lt;P&gt;Thank you for the &lt;CODE&gt;appendpipe&lt;/CODE&gt;. I made the following changes as per my requirement. It is working fine now.&lt;BR /&gt;
Now Success returns &lt;CODE&gt;0&lt;/CODE&gt;, Failure returns &lt;CODE&gt;1&lt;/CODE&gt;, No results found returns &lt;CODE&gt;9&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval final = if(status_="exist", 0, 1) 
| table final
| appendpipe [stats count| eval final=9 | where count==0 |table final]
| outputlookup output.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jan 2017 09:41:01 GMT</pubDate>
    <dc:creator>biec1</dc:creator>
    <dc:date>2017-01-25T09:41:01Z</dc:date>
    <item>
      <title>Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74239#M18678</link>
      <description>&lt;P&gt;How to print a custom message in a table when &lt;STRONG&gt;No results found&lt;/STRONG&gt;, when no logs?&lt;/P&gt;

&lt;P&gt;example search:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index=test | eval msg="No logs!" | table msg&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;No results found.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but I want table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    msg
| No logs! |
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2012 13:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74239#M18678</guid>
      <dc:creator>mewtwo</dc:creator>
      <dc:date>2012-06-13T13:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74240#M18679</link>
      <description>&lt;P&gt;This occurs because the search &lt;CODE&gt;index=test&lt;/CODE&gt; returns no events, which gives &lt;CODE&gt;eval&lt;/CODE&gt; no objects to decorate with the "msg" field.&lt;/P&gt;

&lt;P&gt;Since what you seem to want here is a no-op search, I suggest the following search string, which appears to yield the desired results :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| stats count | eval msg="No logs!" | table msg&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;| stats count&lt;/CODE&gt; essentially acts as a no-op but yields one result that &lt;CODE&gt;eval&lt;/CODE&gt; can then decorate with the "msg" field.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2012 17:39:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74240#M18679</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2012-06-13T17:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74241#M18680</link>
      <description>&lt;P&gt;&lt;CODE&gt;| stats count | eval msg = if(count == 0, "No Msg!","Msgs Exist!") | table msg&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Building from the mighty hexx's answer, I put in an if statement to only show "No Msg!" if there were indeed no events.  eval msg="No logs!" would display the no log message even when it does return.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2012 18:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74241#M18680</guid>
      <dc:creator>mikelanghorst</dc:creator>
      <dc:date>2012-06-13T18:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74242#M18681</link>
      <description>&lt;P&gt;Just looking at the code, you only get a message stating whether data was found or not.   Is there a way to show data when data exists, but the message "No Msg!" if there isn't?  Sorry to rez an old post.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2012 02:08:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74242#M18681</guid>
      <dc:creator>stephenho</dc:creator>
      <dc:date>2012-10-19T02:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74243#M18682</link>
      <description>&lt;P&gt;I also have the same question as stephento&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2013 16:14:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74243#M18682</guid>
      <dc:creator>Splunk_U</dc:creator>
      <dc:date>2013-03-13T16:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74244#M18683</link>
      <description>&lt;P&gt;If you wanted to show results of the instead of "Msgs Exist!" you could do:&lt;/P&gt;

&lt;P&gt;| stats count | eval msg = if(count == 0, "No Msg!",count) | table msg&lt;/P&gt;

&lt;P&gt;Sorry to rez an old post but I am searching for a solution on this as well...&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2014 19:16:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74244#M18683</guid>
      <dc:creator>MattZerfas</dc:creator>
      <dc:date>2014-02-28T19:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74245#M18684</link>
      <description>&lt;P&gt;You are a genius, thank you ! &lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2015 13:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74245#M18684</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2015-02-24T13:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74246#M18685</link>
      <description>&lt;P&gt;Of note, this works with a simple "stats count". It does not work if you split your stats over a field (i.e. stats count by host). &lt;/P&gt;

&lt;P&gt;Also, if using this for a no-volume alert, you can use null as the second argument. Then your alert would be a "if results count &amp;gt; 0".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval status=if(count == 0,"No Volume",null) | table status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Dec 2015 14:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74246#M18685</guid>
      <dc:creator>jeremiahc4</dc:creator>
      <dc:date>2015-12-08T14:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74247#M18686</link>
      <description>&lt;P&gt;I am trying to include logic ,so that it can handle &lt;CODE&gt;No results found&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;When &lt;CODE&gt;No events found&lt;/CODE&gt;,the following returns 9. &lt;BR /&gt;
When &lt;CODE&gt;Events Exist&lt;/CODE&gt; the final field loses its scope after &lt;CODE&gt;stats&lt;/CODE&gt;. &lt;BR /&gt;
&lt;CODE&gt;| eval final = if(count=0,9,final)&lt;/CODE&gt;:- Here the &lt;CODE&gt;final&lt;/CODE&gt; field becomes inaccessible.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval final = if(status_="exist", 0, 1) 
| stats count
| eval final = if(count=0,9,final)
| table final
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To make &lt;CODE&gt;final&lt;/CODE&gt; field accessible after &lt;CODE&gt;stats&lt;/CODE&gt;, i used &lt;CODE&gt;| stats count by final&lt;/CODE&gt; . &lt;BR /&gt;
This created additional problem, when the events are present, &lt;CODE&gt;| stats count by final&lt;/CODE&gt; fails.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval final = if(status_="exist", 0, 1) 
| stats count by final
| eval final = if(count=0,9,final)
| table final
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74247#M18686</guid>
      <dc:creator>biec1</dc:creator>
      <dc:date>2017-01-24T11:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74248#M18687</link>
      <description>&lt;P&gt;Here is a different approach to doing this.  With the query below if it does return results the will be displayed but if the query returns "No results found" then it will display whatever message you have in the eval statement and you can name the column header to whatever you would like as well. Just rename error to something else and change the table to at the end to match that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test |appendpipe [stats count| eval error="Your message here"  | where count==0 |table error]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basicly just put the &lt;CODE&gt;|appendpipe [stats ...&lt;/CODE&gt; after any query and it will display your message if there is no results to display.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:15:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74248#M18687</guid>
      <dc:creator>MattZerfas</dc:creator>
      <dc:date>2017-01-24T14:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74249#M18688</link>
      <description>&lt;P&gt;@biec1 Take a look at my answer I just posted and see if that solves your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74249#M18688</guid>
      <dc:creator>MattZerfas</dc:creator>
      <dc:date>2017-01-24T14:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Table message when No results found.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74250#M18689</link>
      <description>&lt;P&gt;Thank you for the &lt;CODE&gt;appendpipe&lt;/CODE&gt;. I made the following changes as per my requirement. It is working fine now.&lt;BR /&gt;
Now Success returns &lt;CODE&gt;0&lt;/CODE&gt;, Failure returns &lt;CODE&gt;1&lt;/CODE&gt;, No results found returns &lt;CODE&gt;9&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval final = if(status_="exist", 0, 1) 
| table final
| appendpipe [stats count| eval final=9 | where count==0 |table final]
| outputlookup output.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 09:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-message-when-No-results-found/m-p/74250#M18689</guid>
      <dc:creator>biec1</dc:creator>
      <dc:date>2017-01-25T09:41:01Z</dc:date>
    </item>
  </channel>
</rss>

