<?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 edit my search so the alert triggers when the count=0? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296901#M89567</link>
    <description>&lt;P&gt;thats much nicer than my suggestion.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2017 21:00:18 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2017-02-13T21:00:18Z</dc:date>
    <item>
      <title>How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296891#M89557</link>
      <description>&lt;P&gt;I'm looking for a query which write count=0 in the stats result when there are no events for that app and host. &lt;/P&gt;

&lt;P&gt;My search query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XYZ (appid=A OR appId=B) ( host=123 OR host =234 ) | stats count by appid,host 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;An alert should be triggered when the count is 0 from the result. I have tried using appendpipe but it didn't work for me. &lt;/P&gt;

&lt;P&gt;Example: I have added a new host=000 in the above search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XYZ (appid=A OR appId=B) ( host=123 OR host =234 OR host=000) | stats count by appid,host | appendpipe [ stats count by appid,host | count=0 | where count==0] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result is same as the result from first query. I was expecting two extra rows in the result ,something like appId A  host=000 count=0 and appid=B host=000 count=0 &lt;/P&gt;

&lt;P&gt;Is there any other way I can trigger an alert when count=0 for the above scenario. &lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:07:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296891#M89557</guid>
      <dc:creator>nithin204</dc:creator>
      <dc:date>2017-02-13T19:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296892#M89558</link>
      <description>&lt;P&gt;You can use your 1st search itself and when setting up the alert, use the alert condition if number of events - equals to - 0&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:32:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296892#M89558</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2017-02-13T19:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296893#M89559</link>
      <description>&lt;P&gt;Rather than force the query to return "count=0" I prefer to let my search return what it will and set the alert condition to "if number of events", "is equal to", "0".&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:33:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296893#M89559</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-02-13T19:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296894#M89560</link>
      <description>&lt;P&gt;The count=0 will not be displayed in the stats table(result). I guess it works only when there is atleast one event. If host=123 is down, the result will be app A host 234 count and app B host 234 count. There will not be any records for host=123 I believe. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296894#M89560</guid>
      <dc:creator>nithin204</dc:creator>
      <dc:date>2017-02-13T19:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296895#M89561</link>
      <description>&lt;P&gt;The count=0 will not be displayed in the stats table(result). I guess it works only when there is atleast one event. If host=123 is down, the result will be app A host 234 count and app B host 234 count. There will not be any records for host=123 I believe. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:42:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296895#M89561</guid>
      <dc:creator>nithin204</dc:creator>
      <dc:date>2017-02-13T19:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296896#M89562</link>
      <description>&lt;P&gt;The problem with your approach is that if any of your app/host combos stop sending events they will be dropped from your search.&lt;/P&gt;

&lt;P&gt;If I interpret your question correctly - you have two apps, both running on two hosts. You want to know if either app stops sending events on either server?&lt;/P&gt;

&lt;P&gt;Your stats table from: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XYZ (appid=A OR appId=B) ( host=123 OR host =234 ) | stats count by appid,host 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should be returning you 4 rows?&lt;/P&gt;

&lt;P&gt;If I follow correctly so far, you will want to build your alert to trigger when your event count !=4 &lt;BR /&gt;
If any of the apps/servers stop sending logs, your event count will be below 4, and your alert will fire.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296896#M89562</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-13T19:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296897#M89563</link>
      <description>&lt;P&gt;Thanks for your comment. Yes,  This was my approach as well. But I have 4 apps and 4 hosts. So the result will have 16 rows. If I set up a condition if number of events &amp;lt; 16 the alert will trigger but I don't want the users to go and find what server is missing from the lists. I want to send the details of the appId and host in the alert rather than the complete list of results when alert was triggered. Is this possible with lookup's ? Appreciate your help on this. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:55:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296897#M89563</guid>
      <dc:creator>nithin204</dc:creator>
      <dc:date>2017-02-13T19:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296898#M89564</link>
      <description>&lt;P&gt;If you added your desired hosts and appIds into a lookup file, you could start your search with an inputlookup. This would ensure you always have at least 1 event for each host/app combo in your search then you could run stats on the results, and finally a where count=1 would show up just the events which are in the lookup, but not the query.&lt;/P&gt;

&lt;P&gt;i have not tested this, or perhaps even fully thought it through, but I think this could work.&lt;/P&gt;

&lt;P&gt;I'll try and test and give you a full example if I get a chance&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 20:25:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296898#M89564</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-13T20:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296899#M89565</link>
      <description>&lt;P&gt;appId or appid?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 20:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296899#M89565</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-13T20:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296900#M89566</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=XYZ (appid=A OR appId=B) ( host=123 OR host =234 ) | stats count as mycount by host appid 
| append  
[| makeresults | eval host="123 234" | eval appid="A B" | makemv host | makemv appid | mvexpand host | mvexpand appid | eval mycount = 0 ]
| stats sum(mycount) as mycount by appid host
| where mycount = 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2017 20:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296900#M89566</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-13T20:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296901#M89567</link>
      <description>&lt;P&gt;thats much nicer than my suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 21:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296901#M89567</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-02-13T21:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296902#M89568</link>
      <description>&lt;P&gt;It got this error : Unknown search command 'makeresults'&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 21:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296902#M89568</guid>
      <dc:creator>nithin204</dc:creator>
      <dc:date>2017-02-13T21:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296903#M89569</link>
      <description>&lt;P&gt;&lt;CODE&gt;makeresults&lt;/CODE&gt; is a relatively new command.  If your version of Splunk doesn't have it, try &lt;CODE&gt;metadata type=sources | head 1&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 21:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296903#M89569</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-02-13T21:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296904#M89570</link>
      <description>&lt;P&gt;Actually, the lookup table is a more maintainable solution in the long run.  This is a good one for a quick throwaway, though.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 21:28:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296904#M89570</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-13T21:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search so the alert triggers when the count=0?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296905#M89571</link>
      <description>&lt;P&gt;@nithin204 - Looks like you have a few possible solutions to your question. If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post. If you still need help, please leave a comment. Don’t forget to upvote anything that was helpful too. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 00:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-so-the-alert-triggers-when-the-count-0/m-p/296905#M89571</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-03-20T00:28:39Z</dc:date>
    </item>
  </channel>
</rss>

