<?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 use &amp;quot;set diff&amp;quot; and &amp;quot;diff&amp;quot; commands to list out new values in a file comparing different days/weeks/months/years? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408530#M117930</link>
    <description>&lt;P&gt;There is seldom a good use case for &lt;CODE&gt;set diff&lt;/CODE&gt;, and this is not it.  &lt;/P&gt;

&lt;P&gt;Let's ask the question a different way:  how can we find the date/time of the first occurrence of each file?  Well, let's just ask for that, and if the first occurrence is within the last day, 2 days, whatever, then we will mark it as "new".&lt;/P&gt;

&lt;P&gt;Given your code, I'm assuming that &lt;CODE&gt;dest&lt;/CODE&gt; is the name of the file.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    sourcetype=nessus source=Host_Enumeration earliest=-30d
   | fields dest
   | dedup dest
   | stats min(_time) as _time by dest
   | where _time &amp;gt;= relative_time(now(),"-1d@d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Now, the above will work.  For future reference, though, if the information is in the summary statistics, then you really want to be using &lt;CODE&gt;tstats&lt;/CODE&gt; because it is screaming fast.  So, perhaps if we were checking for new sources or sourcetypes, then you'd want to use a tstats method rather than checking laboriously through the individual events.  &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Tstats"&gt;https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Tstats&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 May 2018 17:24:26 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-05-23T17:24:26Z</dc:date>
    <item>
      <title>How to use "set diff" and "diff" commands to list out new values in a file comparing different days/weeks/months/years?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408528#M117928</link>
      <description>&lt;P&gt;I have data which add new files every day. I want to compare today's data with previous day/week/month/year data and list out new files. Is it possible to list out? I have gone through Splunk answers to find solutions. I found below search to compare files from yesterday. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=nessus source=*Host_Enumeration* earliest=-1d@d latest=now NOT [search sourcetype=nessus source=*Host_Enumeration* earliest=-3d@d latest=-2d@d | stats count by dest_ip | dest_ip]| stats count by dest_ip | dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I changed the time-range in the search to find new files from previous week/month/year as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=nessus source=*Host_Enumeration* earliest=-1d@d latest=now NOT [search sourcetype=nessus source=*Host_Enumeration* earliest=-6w@d latest=-2d@d | stats count by dest_ip | dest_ip]| stats count by dest_ip | dest_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the above code, the result has previous day &lt;CODE&gt;(earliest=-3d@d latest=-2d@d)&lt;/CODE&gt; files. &lt;/P&gt;

&lt;P&gt;Why it is listing previous files? Is there any other possibility to find solution for this scenario?&lt;/P&gt;

&lt;P&gt;Thanks in Advance&lt;BR /&gt;
Chandana&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 16:47:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408528#M117928</guid>
      <dc:creator>chandana204</dc:creator>
      <dc:date>2018-05-23T16:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use "set diff" and "diff" commands to list out new values in a file comparing different days/weeks/months/years?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408529#M117929</link>
      <description>&lt;P&gt;updated to mark code.  &lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 17:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408529#M117929</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-05-23T17:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use "set diff" and "diff" commands to list out new values in a file comparing different days/weeks/months/years?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408530#M117930</link>
      <description>&lt;P&gt;There is seldom a good use case for &lt;CODE&gt;set diff&lt;/CODE&gt;, and this is not it.  &lt;/P&gt;

&lt;P&gt;Let's ask the question a different way:  how can we find the date/time of the first occurrence of each file?  Well, let's just ask for that, and if the first occurrence is within the last day, 2 days, whatever, then we will mark it as "new".&lt;/P&gt;

&lt;P&gt;Given your code, I'm assuming that &lt;CODE&gt;dest&lt;/CODE&gt; is the name of the file.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    sourcetype=nessus source=Host_Enumeration earliest=-30d
   | fields dest
   | dedup dest
   | stats min(_time) as _time by dest
   | where _time &amp;gt;= relative_time(now(),"-1d@d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Now, the above will work.  For future reference, though, if the information is in the summary statistics, then you really want to be using &lt;CODE&gt;tstats&lt;/CODE&gt; because it is screaming fast.  So, perhaps if we were checking for new sources or sourcetypes, then you'd want to use a tstats method rather than checking laboriously through the individual events.  &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Tstats"&gt;https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Tstats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 17:24:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408530#M117930</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-05-23T17:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use "set diff" and "diff" commands to list out new values in a file comparing different days/weeks/months/years?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408531#M117931</link>
      <description>&lt;P&gt;Thank you for your response. My main issue in this task is list out new files. here new files means files are not existed in previous data . If i use above query I can't list out new files but i can see all files with timestamp. Unfortunately, this is not the answer what I am looking for. &lt;/P&gt;

&lt;P&gt;To understanding more i'll give an example&lt;/P&gt;

&lt;P&gt;today:                  r, t, y, w, h, g, u, o, p, l, i, a, c&lt;/P&gt;

&lt;P&gt;yesterday:          &lt;STRONG&gt;y&lt;/STRONG&gt;, &lt;STRONG&gt;i&lt;/STRONG&gt;, &lt;STRONG&gt;c&lt;/STRONG&gt;, b, f, j, 1, 9, 5, 3, aa, gf, br, rh&lt;BR /&gt;
last week:           &lt;STRONG&gt;w&lt;/STRONG&gt;, &lt;STRONG&gt;g&lt;/STRONG&gt;, fg, rd, &lt;STRONG&gt;o&lt;/STRONG&gt;, ff, ht, og, &lt;STRONG&gt;c&lt;/STRONG&gt;, &lt;STRONG&gt;y&lt;/STRONG&gt;&lt;BR /&gt;
last 6 months:     &lt;STRONG&gt;y&lt;/STRONG&gt;, hd, jw, &lt;STRONG&gt;o&lt;/STRONG&gt;, &lt;STRONG&gt;r&lt;/STRONG&gt;, kd, rd&lt;BR /&gt;
last year:            sd, ed, ewe, ui, oo, kas, &lt;STRONG&gt;w&lt;/STRONG&gt;, &lt;STRONG&gt;c&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Different files in today's data: t, h, u, p, l, a&lt;BR /&gt;
The rest of the files are occurred in yesterday, last week, last 6 months and last year. &lt;/P&gt;

&lt;P&gt;Can i get the result as above using splunk tool?&lt;/P&gt;

&lt;P&gt;I already mentioned this point but i'm again mentioning i.e., the search query what I have mentioned in my question, it is working fine but it is listing different files from previous day only. My requirement is, I want compare all files from previous week/month/year too.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Chandana&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:15:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-quot-set-diff-quot-and-quot-diff-quot-commands-to/m-p/408531#M117931</guid>
      <dc:creator>chandana204</dc:creator>
      <dc:date>2018-05-23T18:15:10Z</dc:date>
    </item>
  </channel>
</rss>

