<?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: Count of set diff from previous bucket in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-of-set-diff-from-previous-bucket/m-p/94918#M24530</link>
    <description>&lt;P&gt;This problem is similar to the one described in &lt;A href="http://splunk-base.splunk.com/answers/34666/how-do-i-get-results-in-search-a-that-are-not-in-search-b"&gt;how-do-i-get-results-in-search-a-that-are-not-in-search-b&lt;/A&gt;. Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=client | eval happened_recently=if(relative_time(now(),"@d")&amp;lt;=_time,1,0) | eval happened_before=if(relative_time(now(),"@d")&amp;gt;_time,1,0) | stats sum(happened_recently) AS recent, sum(happened_before) AS before by deviceId | search recent=0 OR before=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will show all the deviceIds which have either shown up in the past, but not today (the "recently missing"), or show up today, but not in the past (the "recently appeared").  You can obviously tweak the final search term to show only "recently missing" or "recently appeared".&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2012 07:46:25 GMT</pubDate>
    <dc:creator>dmillis</dc:creator>
    <dc:date>2012-09-07T07:46:25Z</dc:date>
    <item>
      <title>Count of set diff from previous bucket</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-set-diff-from-previous-bucket/m-p/94917#M24529</link>
      <description>&lt;P&gt;I'm trying to produce a report that shows the difference between new and missing IDs from one day to the next day over a period of time. I've looked into &lt;A href="http://splunk-base.splunk.com/answers/13304/compare-two-sets-of-data-from-different-times"&gt;this answer&lt;/A&gt; but I'm not sure how to apply it to my problem.&lt;/P&gt;

&lt;P&gt;The base query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=client | bucket _time span=1d | stats values(deviceId) by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me a set of distinct device IDs. How do I get a set of distinct device IDs from the previous day so that I can get a count of the IDs that are new and removed so that I can get a report such as this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date | Total | New | Removed
----------------------------
 x     5       0     1
 x+1   6       2     1
 x+2   9       3     0       
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2012 20:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-set-diff-from-previous-bucket/m-p/94917#M24529</guid>
      <dc:creator>jberd126</dc:creator>
      <dc:date>2012-07-10T20:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count of set diff from previous bucket</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-of-set-diff-from-previous-bucket/m-p/94918#M24530</link>
      <description>&lt;P&gt;This problem is similar to the one described in &lt;A href="http://splunk-base.splunk.com/answers/34666/how-do-i-get-results-in-search-a-that-are-not-in-search-b"&gt;how-do-i-get-results-in-search-a-that-are-not-in-search-b&lt;/A&gt;. Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=client | eval happened_recently=if(relative_time(now(),"@d")&amp;lt;=_time,1,0) | eval happened_before=if(relative_time(now(),"@d")&amp;gt;_time,1,0) | stats sum(happened_recently) AS recent, sum(happened_before) AS before by deviceId | search recent=0 OR before=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will show all the deviceIds which have either shown up in the past, but not today (the "recently missing"), or show up today, but not in the past (the "recently appeared").  You can obviously tweak the final search term to show only "recently missing" or "recently appeared".&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 07:46:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-of-set-diff-from-previous-bucket/m-p/94918#M24530</guid>
      <dc:creator>dmillis</dc:creator>
      <dc:date>2012-09-07T07:46:25Z</dc:date>
    </item>
  </channel>
</rss>

