<?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 search the count of adds/removes (new hosts vs host decoms) month on month? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206512#M60105</link>
    <description>&lt;P&gt;Also if I add 1 host and remove another host in a month, the stats will be the same and the delta zero but we had movement...&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2016 14:53:31 GMT</pubDate>
    <dc:creator>smudge797</dc:creator>
    <dc:date>2016-06-10T14:53:31Z</dc:date>
    <item>
      <title>How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206506#M60099</link>
      <description>&lt;P&gt;What I want is to many adds/removes (new hosts vs host decoms) month on month&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | stats dc(Host_Name) by date_month 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So take Jan ... there are 160226 distinct hosts &lt;BR /&gt;
Feb number is 162359&lt;BR /&gt;
That could be something like 190 hosts were removed and 2323 were added in Feb&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206506#M60099</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-10T13:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206507#M60100</link>
      <description>&lt;P&gt;Assuming you're just comparing host count for (last) two consecutive month, give this a shot&lt;/P&gt;

&lt;P&gt;(Based on your example query, you're not using splunk's default host field, so this will be slower) &lt;BR /&gt;
&lt;STRONG&gt;Updated&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* earliest=-2mon@mon latest=@mon | stats values(date_month) as month by host | eval Type=case(mvcount(month)=1 AND month=relative_time(now(),"-2mon@mon"),"Removed",mvcount(month)=1 AND month=relative_time(now(),"@mon"),"Added",1=1,"Same" ) | chart count by Type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206507#M60100</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-10T13:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206508#M60101</link>
      <description>&lt;P&gt;Error in 'eval' command: The expression is malformed. Expected ). &lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:38:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206508#M60101</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-10T13:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206509#M60102</link>
      <description>&lt;P&gt;Try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | timechart span=1m dc(Host_Name) as Count_Of_Hosts 
| streamstats window=2 last(Count_Of_Hosts) AS Last, first(Count_Of_Hosts) AS First 
| eval Delta=Last-First
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, we have our base search then feed that to timechart splitting things by month.  You can TOTALLY use bin+stats, which would be more efficient, but I think as an example this is more clear yet is only slightly slower.&lt;/P&gt;

&lt;P&gt;That goes into streamstats which takes those events two at a time ( &lt;CODE&gt;window=2&lt;/CODE&gt; ) and sets &lt;CODE&gt;Last&lt;/CODE&gt; and &lt;CODE&gt;First&lt;/CODE&gt; to the count from the existing event and the preceding event.  This makes the last line a simple subtraction on each event.&lt;/P&gt;

&lt;P&gt;As it stands, all those fields will be output, so you can see what it does yourself and confirm.  If you don't need those extra fields, you can always &lt;CODE&gt;| table ...&lt;/CODE&gt; the ones you want or &lt;CODE&gt;| fields - ...&lt;/CODE&gt; to get rid of the ones you don't want.&lt;/P&gt;

&lt;P&gt;For reference in case I fat fingered the changes to fit your own use case better, here's the test I ran on my laptop (which has only local logs and miscellaneous stuff I'm testing for answers):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | timechart span=1w dc(eventtype) as EventTypes | streamstats window=2 last(EventTypes) AS Last, first(EventTypes) AS First | eval Delta=Last-First
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206509#M60102</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-06-10T13:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206510#M60103</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* earliest=-1mon@mon | eval when=if(_time&amp;lt;relative_time(now(), "@mon"), "Prev", "Current")  | chart dc(host) as h over host by when | eval action=case(Current&amp;gt;Prev, "Added", Current&amp;lt;Prev, "Removed", 1=1, "No Change") | stats count by action
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206510#M60103</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-10T13:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206511#M60104</link>
      <description>&lt;P&gt;This seems to be getting there!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1m dc(Host_Name) as Count_Of_Hosts 
 | streamstats window=2 last(Count_Of_Hosts) AS Last, first(Count_Of_Hosts) AS First 
 | eval Delta=Last-First
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm seeing this in the UI &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;The specified span would result in too many (&amp;gt;50000) rows.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could be faster without span and timechart?  Maybe just stats?&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 13:58:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206511#M60104</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-10T13:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206512#M60105</link>
      <description>&lt;P&gt;Also if I add 1 host and remove another host in a month, the stats will be the same and the delta zero but we had movement...&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 14:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206512#M60105</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-10T14:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206513#M60106</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;
What do you think?  Is there away to show that movement of host?&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 21:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206513#M60106</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-12T21:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206514#M60107</link>
      <description>&lt;P&gt;do you just need the delta between the columns or do you need an accurate number? If you need accuracy, then you need to track the distinct values of &lt;CODE&gt;Host_Name&lt;/CODE&gt; kept for each column and you need to compare these sets.  The former is pretty easy, the latter, depending on the order of magnitude of your sets, much less so.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 20:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206514#M60107</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-13T20:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206515#M60108</link>
      <description>&lt;P&gt;an accurate number so movement + or - is tracked.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 20:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206515#M60108</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-13T20:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206516#M60109</link>
      <description>&lt;P&gt;First of all, DO NOT use the "free" (but wrong) &lt;CODE&gt;date_*&lt;/CODE&gt; values; calculate your own or use &lt;CODE&gt;| bucket _time span=1mon&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You can only calculate changes in distinctness by comparing each entire list against other lists (not by subtracting dc values) so I would use a monthly Summary Index to store a list of distinct hosts and then build your search to pull from that aggregate store.  You can use &lt;CODE&gt;sistats&lt;/CODE&gt; to help you with this:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.4/SearchReference/Sistats"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.4/SearchReference/Sistats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206516#M60109</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-13T22:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206517#M60110</link>
      <description>&lt;P&gt;Hi Greg,&lt;BR /&gt;
Still struggling with this can you provide anymore instructions?  The data is summarized but im struggling with the query.&lt;/P&gt;

&lt;P&gt;| bucket _time span=1mon | sistats dc(Host_Name) by _time&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:58:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206517#M60110</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2020-09-29T09:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206518#M60111</link>
      <description>&lt;P&gt;That should be pretty much it.  What problem are you having, exactly?  What is your SI-populating search?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2016 11:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206518#M60111</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-21T11:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206519#M60112</link>
      <description>&lt;P&gt;Here is the SI search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... source=*.csv | eval IMT = substr(Cost,2)| convert rmcomma(IMT) | eval Total=round(IMT,2) | stats sum("Total") as Cost by Date "Cost Center" "Org L5" "Org L6" Org_Description IIGL1 IIGL2 IIGL3 IIGL4 Product Feed_Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 12:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206519#M60112</guid>
      <dc:creator>smudge797</dc:creator>
      <dc:date>2016-06-27T12:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the count of adds/removes (new hosts vs host decoms) month on month?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206520#M60113</link>
      <description>&lt;P&gt;I do not see &lt;CODE&gt;sistats&lt;/CODE&gt; in your search and this search looks nothing like your original search..  If you are planning to us the &lt;CODE&gt;dc&lt;/CODE&gt; function coming back out of your SI, you really need to use &lt;CODE&gt;sistats&lt;/CODE&gt; (like I said in my answer) because it does all the crazy magic for you:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/sistats"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/sistats&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* | sistats dc(Host_Name) by date_month 

index=YourSummaryIndex | stats dc(Host_Name) by date_month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is the answer for &lt;EM&gt;THIS&lt;/EM&gt; question.  However it appears that your needs have morphed completely away from the original question so perhaps you should start another question.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 12:42:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-count-of-adds-removes-new-hosts-vs-host-decoms/m-p/206520#M60113</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-27T12:42:46Z</dc:date>
    </item>
  </channel>
</rss>

