<?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: stats count zeroes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368926#M108735</link>
    <description>&lt;P&gt;Is there an option to not show the field "Success by Host" if successes=0 ? (e.g. show the field but no value?)&lt;BR /&gt;
EDIT: To clarify, hosts that have no successful logins could show a blank (&lt;CODE&gt;" "&lt;/CODE&gt;) instead of &lt;CODE&gt;successes=0&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Sep 2017 07:22:28 GMT</pubDate>
    <dc:creator>christoffertoft</dc:creator>
    <dc:date>2017-09-29T07:22:28Z</dc:date>
    <item>
      <title>stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368920#M108729</link>
      <description>&lt;P&gt;I have the following search term&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | 
| stats count(eval(action="failure")) as fails, count(eval(action="success")) as successes by user, host
| stats list(host) as "Hosts Contacted", dc(host) as "Count of Hosts", list(fails) as "Fails per Hostname", count(fails) as "Total Fails", count(successes) as "Successful Logins" by user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Im getting a table like follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user.................hosts contacted...count of hosts,......fails per hostname...........total fails...........successful logins
username1............somehost.................2................1...................................2...........................2
.....................somehost2.................................1................................................................ 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As we can see, the query unsuccessfully determines the result of the login attempts. For comparison, if i add &lt;CODE&gt;list(fails)&lt;/CODE&gt; to the final &lt;CODE&gt;stats&lt;/CODE&gt; command they will show up as 0s, but the column with Total fails will still add them up. Does my query count 0s as values and add them in the &lt;CODE&gt;count()&lt;/CODE&gt; function, or am I missing something else here? The goal is to list amount of fails and successful logins (e.g) display the total amount of failed logins per host and the amount of successful logins, grouped by a user.  Essentially, it's the same for the successful logins, if i have 4 successful logins and 0 failed, both columns will show 4.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 14:57:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368920#M108729</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-09-28T14:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368921#M108730</link>
      <description>&lt;P&gt;Sorry for the bad formatting, I don't know how to tabulate data..&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 15:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368921#M108730</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-09-28T15:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368922#M108731</link>
      <description>&lt;P&gt;What's the outcome of just the first stats statement?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; .... | 
 | stats count(eval(action="failure")) as fails, count(eval(action="success")) as successes by user, host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2017 15:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368922#M108731</guid>
      <dc:creator>grittonc</dc:creator>
      <dc:date>2017-09-28T15:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368923#M108732</link>
      <description>&lt;P&gt;Your second &lt;CODE&gt;stats&lt;/CODE&gt; needs to use &lt;CODE&gt;sum()&lt;/CODE&gt; rather than &lt;CODE&gt;count()&lt;/CODE&gt;.  You can also create a synthetic field to connect the count of fails or successes to the appropriate host name.&lt;/P&gt;

&lt;P&gt;Try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count(eval(action="failure")) as fails, count(eval(action="success")) as successes by user, host
 | eval hostfails = "host=".host." fails=".fails
 | eval hostsucc = "host=".host." successes=".successes
 | stats values(host) as "Hosts Contacted", dc(host) as "Count of Hosts", 
         values(hostfails) as "Fails by Host","
         sum(fails) as "Total Fails",
         values(hostsucc) as "Success by Host",
         sum(successes) as "Total Successful Logins" 
         by user
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2017 16:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368923#M108732</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-28T16:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368924#M108733</link>
      <description>&lt;P&gt;&lt;CODE&gt;fails&lt;/CODE&gt; will be either 0 or 1, and the same for &lt;CODE&gt;successes&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;something like: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;user1-------- host1-----1---0&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;user2---------host1-----1---1&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 07:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368924#M108733</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-09-29T07:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368925#M108734</link>
      <description>&lt;P&gt;Wow, this helped! thanks alot for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 07:09:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368925#M108734</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-09-29T07:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368926#M108735</link>
      <description>&lt;P&gt;Is there an option to not show the field "Success by Host" if successes=0 ? (e.g. show the field but no value?)&lt;BR /&gt;
EDIT: To clarify, hosts that have no successful logins could show a blank (&lt;CODE&gt;" "&lt;/CODE&gt;) instead of &lt;CODE&gt;successes=0&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 07:22:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368926#M108735</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2017-09-29T07:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: stats count zeroes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368927#M108736</link>
      <description>&lt;P&gt;option 1 - leave them off completely...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval hostfails =  case(fails&amp;gt;0,"host=".host." fails=".fails)
 | eval hostsucc = case(successes&amp;gt;0,"host=".host." successes=".successes)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;option 2 - list the name without anything after it...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval hostfails =  "host=".host.if(fails&amp;gt;0," fails=".fails,"")
 | eval hostsucc = "host=".host.if(successes&amp;gt;0," successes=".successes,"")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 14:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-zeroes/m-p/368927#M108736</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-29T14:19:17Z</dc:date>
    </item>
  </channel>
</rss>

