<?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 do I combine  &amp;quot;  |stats count by host &amp;quot;  and  &amp;quot;| stats distinct_count(host)&amp;quot;   in one table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396640#M115175</link>
    <description>&lt;P&gt;I think what I need is this &lt;A href="https://answers.splunk.com/answers/614705/how-to-trigger-second-search-based-on-first-search.html"&gt;https://answers.splunk.com/answers/614705/how-to-trigger-second-search-based-on-first-search.html&lt;/A&gt;  &lt;/P&gt;

&lt;P&gt;So first search and alert on the distinct number of hosts (with my condition) then trigger a second search that give more details.   I'll give it a try and report back. &lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2018 14:13:13 GMT</pubDate>
    <dc:creator>pretzel2</dc:creator>
    <dc:date>2018-10-02T14:13:13Z</dc:date>
    <item>
      <title>How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396637#M115172</link>
      <description>&lt;P&gt;I can search for events and run stats count by host.  &lt;/P&gt;

&lt;P&gt;And I can run a search of distinct number of hosts.&lt;/P&gt;

&lt;P&gt;I want to combine both in one table. I want count of events by host and a count of hosts.&lt;/P&gt;

&lt;P&gt;I actually want to create an alert based on the number of hosts returned. &lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 21:56:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396637#M115172</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-01T21:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396638#M115173</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| stats count, dc(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should work just fine, you can create alerts that work on the number of rows returned, or you can use a &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Alert/AlertTriggerConditions"&gt;Custom Triggering Condition&lt;/A&gt; to trigger only when criteria are met &lt;EM&gt;or&lt;/EM&gt; you could integrate it into your search, for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count, dc(host) AS distinctCount by host
| where distinctCount &amp;gt; 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then alert when more than 0 results appear&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 22:03:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396638#M115173</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2018-10-01T22:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396639#M115174</link>
      <description>&lt;P&gt;Thank you for the reply!   The first suggestion works, sort of.  I get a table with a columns,  host, count, and distinctCount.  distinctCount for each host is "1".   When I add the where condition it doesn't work.&lt;BR /&gt;
I have to move where distinctCount &amp;gt; 0  to get any table. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 13:15:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396639#M115174</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-02T13:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396640#M115175</link>
      <description>&lt;P&gt;I think what I need is this &lt;A href="https://answers.splunk.com/answers/614705/how-to-trigger-second-search-based-on-first-search.html"&gt;https://answers.splunk.com/answers/614705/how-to-trigger-second-search-based-on-first-search.html&lt;/A&gt;  &lt;/P&gt;

&lt;P&gt;So first search and alert on the distinct number of hosts (with my condition) then trigger a second search that give more details.   I'll give it a try and report back. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 14:13:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396640#M115175</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-02T14:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396641#M115176</link>
      <description>&lt;P&gt;Using the "map" command worked,  in this case triggering second search if threshold of 2 or more is reached.&lt;/P&gt;

&lt;P&gt;index= source= host="something*" &lt;BR /&gt;
| stats distinct_count(host) as distcounthost&lt;/P&gt;

&lt;P&gt;| eval tokenForSecondSearch=case(distcounthost&amp;gt;=2,"true")&lt;/P&gt;

&lt;P&gt;| map search="search index= source= host="something*"&lt;BR /&gt;
| stats count by host,source | sort - count"&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 15:30:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396641#M115176</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-02T15:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396642#M115177</link>
      <description>&lt;P&gt;hi @pretzel2 &lt;/P&gt;

&lt;P&gt;It looks like you and @gjanders were able to figure out your query. Would you mind approving this answer if it helped ya? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 20:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396642#M115177</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-10-02T20:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396643#M115178</link>
      <description>&lt;P&gt;thought I had map working .. as a second search but it's not working .. I get 10000 stats and think I'm running Splunk into the ground.    My basic point is this, I want to create an alert based on a count of something (that works) but then I want to send my ops team more details about the alert, hostname, ldap server, etc,  fields that I already have defined.    Maybe put that in a report and tie that to the alert using map? &lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 20:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396643#M115178</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-02T20:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396644#M115179</link>
      <description>&lt;P&gt;I think trigger conditions is the way to go. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 20:39:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396644#M115179</guid>
      <dc:creator>pretzel2</dc:creator>
      <dc:date>2018-10-02T20:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine  "  |stats count by host "  and  "| stats distinct_count(host)"   in one table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396645#M115180</link>
      <description>&lt;P&gt;I think if you use the trigger condition or a where clause to filter out the data you want, you might also want to look at eventstats.&lt;/P&gt;

&lt;P&gt;index= source= host="something*"&lt;BR /&gt;
| eventstats distinct_count(host) as distcounthost&lt;BR /&gt;
| where distcounthost &amp;gt; 1&lt;/P&gt;

&lt;P&gt;Would for example add the "distcounthost" to each event but not lose the raw data, so you won't need a map or a report + alert...&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 21:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-combine-quot-stats-count-by-host-quot-and-quot-stats/m-p/396645#M115180</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2018-10-02T21:46:57Z</dc:date>
    </item>
  </channel>
</rss>

