<?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: help with counting search events / output needed in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461142#M130058</link>
    <description>&lt;P&gt;Add below after your stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| appendpipe [| stats count as Total| where Total=0 ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Feb 2020 14:33:35 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-02-04T14:33:35Z</dc:date>
    <item>
      <title>help with counting search events / output needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461140#M130056</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I need a help with counting the search results.&lt;BR /&gt;
I cannot use the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;because the stats command destroys my output that I got from the database. On the simple example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| noop search_optimization=false| dbxquery query="
select now() from dummy
" connection="HANA_MLBSO"

| stats count as Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get only a Total under the Statistics tab as a result, otherwise the date coming from now().&lt;BR /&gt;
My goal is to trigger the custom command at the end of search, but only then if the search returned any results, be it events or dbxquery output. Something like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mlbso sourcetype=isp_hanatraces secondary

| stats count as Total

| where Total &amp;gt; 0 

| eval SEVERITY = 3
| eval AlertSource = "SPLUNK"
| eval AlertText = "Test"
| eval  ShortText = "HANA crash" 
| eval SID = "SID"
| eval DB = "DBSID"
| eval host = host
| eval _time = "TIME"
| mycommand
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, for the example above it would maybe even work as there are events returned, but for the DB output of the dbxquery not.&lt;/P&gt;

&lt;P&gt;Is there any elegant way to check if the result returned is not empty without deploying stats?&lt;/P&gt;

&lt;P&gt;Kind REgards,&lt;BR /&gt;
Kamil&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 12:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461140#M130056</guid>
      <dc:creator>damucka</dc:creator>
      <dc:date>2020-02-04T12:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: help with counting search events / output needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461141#M130057</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;stats count as Total, values(*) as *&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 14:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461141#M130057</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-04T14:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: help with counting search events / output needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461142#M130058</link>
      <description>&lt;P&gt;Add below after your stats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| appendpipe [| stats count as Total| where Total=0 ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2020 14:33:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-counting-search-events-output-needed/m-p/461142#M130058</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-02-04T14:33:35Z</dc:date>
    </item>
  </channel>
</rss>

