<?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 Problem with the diff command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-the-diff-command/m-p/74328#M18717</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;Every time a user enters my system, I report his userId.&lt;BR /&gt;
I tried using the DIFF operation to find out which userIds entered my system in the past 7 days but didn't enter in the past 3 days.&lt;/P&gt;

&lt;P&gt;I used the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-7d | fields userId] [search userId earliest=-3d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This didn't work. It seems like Splunk ignored my request to search for the &lt;STRONG&gt;last 7 days of reports&lt;/STRONG&gt; and actually queried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-1d | fields userId] [search userId earliest=-1d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I came to this conclusion by doing the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-1d | fields userId] [search userId earliest=-0d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 0 results)&lt;/P&gt;

&lt;P&gt;and compared it with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-7d | fields userId] [search userId earliest=-0d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 1000 results)&lt;BR /&gt;
and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;userId earliest=-7d | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 1000 results)&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Sun, 19 Feb 2012 04:51:43 GMT</pubDate>
    <dc:creator>ysdeos</dc:creator>
    <dc:date>2012-02-19T04:51:43Z</dc:date>
    <item>
      <title>Problem with the diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-the-diff-command/m-p/74328#M18717</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;Every time a user enters my system, I report his userId.&lt;BR /&gt;
I tried using the DIFF operation to find out which userIds entered my system in the past 7 days but didn't enter in the past 3 days.&lt;/P&gt;

&lt;P&gt;I used the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-7d | fields userId] [search userId earliest=-3d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This didn't work. It seems like Splunk ignored my request to search for the &lt;STRONG&gt;last 7 days of reports&lt;/STRONG&gt; and actually queried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-1d | fields userId] [search userId earliest=-1d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I came to this conclusion by doing the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-1d | fields userId] [search userId earliest=-0d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 0 results)&lt;/P&gt;

&lt;P&gt;and compared it with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-7d | fields userId] [search userId earliest=-0d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 1000 results)&lt;BR /&gt;
and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;userId earliest=-7d | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(returned 1000 results)&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2012 04:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-the-diff-command/m-p/74328#M18717</guid>
      <dc:creator>ysdeos</dc:creator>
      <dc:date>2012-02-19T04:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with the diff command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-the-diff-command/m-p/74329#M18718</link>
      <description>&lt;P&gt;Using set diff will return the results that are &lt;EM&gt;not&lt;/EM&gt; common to both subsearches. You are searching over all 7 days in your first subsearch and then the last three days, this will create an overlap (so the results will be the same).&lt;/P&gt;

&lt;P&gt;What happens if you also set the latest too?&lt;BR /&gt;
Something like;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [search userId earliest=-7d@d latest=-4d@d | fields userId] [search userId earliest=-3d@d | fields userId] | stats count by userId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not able to test this so sorry if its not quite right, just going off the docs. Also my times may be slightly out of sync, too early in the morning for thinking &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2012 10:57:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-the-diff-command/m-p/74329#M18718</guid>
      <dc:creator>Drainy</dc:creator>
      <dc:date>2012-02-19T10:57:55Z</dc:date>
    </item>
  </channel>
</rss>

