<?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 find records that only exist in a particular time range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181877#M52411</link>
    <description>&lt;P&gt;Thanks but how should I go about joining the results from two different time ranges.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Oct 2014 15:35:03 GMT</pubDate>
    <dc:creator>vjverma</dc:creator>
    <dc:date>2014-10-23T15:35:03Z</dc:date>
    <item>
      <title>How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181875#M52409</link>
      <description>&lt;P&gt;I need to query the logs to find records with names that only exists in the current month but not in the previous month (or ever). &lt;/P&gt;

&lt;P&gt;The SQL equivalent would be something on these lines&lt;/P&gt;

&lt;P&gt;select * FROM visitors where datevisit &amp;gt;= '10/1/2014' and datevisit &amp;lt;= '10/31/2014'  AS Oct_Visits&lt;BR /&gt;
Outer join visitors where datevisit &amp;gt;= '9/1/2014' and datevisit &amp;lt;= '9/30/2014' as Sep_Visits&lt;BR /&gt;
ON Oct_Visits.name = Sep_Visits.name AND Sep_Visits.name = null&lt;/P&gt;

&lt;P&gt;Appreciate your help!&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Vijay&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181875#M52409</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2020-09-28T18:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181876#M52410</link>
      <description>&lt;P&gt;Add the following to your main search:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;earliest=@mon&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This tells your search to "snap" the &lt;CODE&gt;earliest&lt;/CODE&gt; time in your search to the beginning of the current month.&lt;/P&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.4/Search/Specifytimemodifiersinyoursearch"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.4/Search/Specifytimemodifiersinyoursearch&lt;/A&gt; for more details on this subject.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 15:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181876#M52410</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-23T15:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181877#M52411</link>
      <description>&lt;P&gt;Thanks but how should I go about joining the results from two different time ranges.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 15:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181877#M52411</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2014-10-23T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181878#M52412</link>
      <description>&lt;P&gt;Something like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=visitors earliest=@mon NOT [search sourcetype=visitors earliest=-1mon@mon latest=@mon | table name | dedup name]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 16:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181878#M52412</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-23T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181879#M52413</link>
      <description>&lt;P&gt;I tried:&lt;/P&gt;

&lt;P&gt;source=visitors earliest=-1mon@mon latest=@mon &lt;STRONG&gt;NOT [search source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name]&lt;/STRONG&gt; | stats count&lt;/P&gt;

&lt;P&gt;The result is same with or without the NOT clause. It appears that when the query runs, the time frame is set to last month and hence the inner search does not kick in. &lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 18:55:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181879#M52413</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2014-10-27T18:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181880#M52414</link>
      <description>&lt;P&gt;Shouldn't be. The inner search is actually run first. As a subsearch, this creates something like &lt;CODE&gt;((name="a") OR (name="b") OR (name="c"))&lt;/CODE&gt; . By putting a &lt;CODE&gt;NOT&lt;/CODE&gt; in front of this, you should be negating the contents of that, so that you only see things that don't match it.&lt;/P&gt;

&lt;P&gt;What results do you get when you just do the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name | format
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By adding the &lt;CODE&gt;format&lt;/CODE&gt; command to the end, you should get the string that is generated as the subsearch for your main search above. Is it what you think it is supposed to be?&lt;/P&gt;

&lt;P&gt;(Also note, this may not work with a real-time search. Choose any other kind of search with the time picker to see the results properly.)&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 19:20:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181880#M52414</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-27T19:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181881#M52415</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=visitors earliest=-4mon@mon latest=@mon | eval Month=strftime(_time,"%Y-%m") | stats values(Month) as Month by name | where mvcount(Month)=1 AND Month=[|gentimes start=-1 | addinfo | eval search="\"".strftime(relative_time(info_max_time,"-1mon"),"%Y-%m")."\"" | return $search]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Oct 2014 19:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181881#M52415</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-10-27T19:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181882#M52416</link>
      <description>&lt;P&gt;When I run this individually, the result list looks okay. I haven't tried the format that you suggested but I see results come back when I run just "source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name" with "All time" option. &lt;/P&gt;

&lt;P&gt;It is only when I execute "source=visitors earliest=-1mon@mon latest=@mon NOT [search source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name] | stats count" that the result doesn't look accurate. &lt;/P&gt;

&lt;P&gt;Also, I see the following lines above the results window that tell me the timeframe is not being picked up correctly.&lt;/P&gt;

&lt;P&gt;[subsearch]: Your timerange was substituted based on your search string&lt;BR /&gt;
[subsearch]: No matching fields exist&lt;BR /&gt;
 ≥ 1 result during September 2014&lt;/P&gt;

&lt;P&gt;If I run the sub-query on its own, the timeframe indicated is correct "June through August"&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 19:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181882#M52416</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2014-10-27T19:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181883#M52417</link>
      <description>&lt;P&gt;Right, because the main search is during September. That is what you would expect to see.&lt;/P&gt;

&lt;P&gt;What makes you believe the result doesn't "look accurate?" By adding a &lt;CODE&gt;stats count&lt;/CODE&gt; to the end of it, you're not inspecting the data but guessing based on a statistic. You need to inspect the data in order to see whether it's actually doing what you want or not.&lt;/P&gt;

&lt;P&gt;Instead of doing a &lt;CODE&gt;stats count&lt;/CODE&gt; at the end, why not replace it with a &lt;CODE&gt;table name | dedup name&lt;/CODE&gt; there, too? That should at least get you some data to inspect: it should be a list of names that logged in during September that did not log in between June and August. Once you have that list, do some searches between June and August on those names, and they shouldn't show up there.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 19:56:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181883#M52417</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-27T19:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181884#M52418</link>
      <description>&lt;P&gt;This is a little crazy, but it does most of the job. I think some tweaking might be in order, though:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Replacing &lt;CODE&gt;info_max_time&lt;/CODE&gt; with &lt;CODE&gt;info_search_time&lt;/CODE&gt; will make it dependent on when you actually execute the search, not the latest time in the time picker window. Otherwise, if your time picker has a range in it that doesn't extend to a day in the current month, your results will be off.&lt;/LI&gt;
&lt;LI&gt;Replacing &lt;CODE&gt;stats values(Month)&lt;/CODE&gt; with &lt;CODE&gt;stats count values(Month)&lt;/CODE&gt; will add the event count information you seem to be looking for.&lt;/LI&gt;
&lt;LI&gt;Adding &lt;CODE&gt;| fields - Month&lt;/CODE&gt; will remove the &lt;CODE&gt;Month&lt;/CODE&gt; column from the result table, so you'll just have event count by &lt;CODE&gt;name&lt;/CODE&gt;. Alternatively, if you just want a total count of events rather than a count by &lt;CODE&gt;name&lt;/CODE&gt;, you can add &lt;CODE&gt;| stats sum(count) as count&lt;/CODE&gt; instead.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 27 Oct 2014 20:28:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181884#M52418</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-27T20:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181885#M52419</link>
      <description>&lt;P&gt;These two queries return the same result as a list and count.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;source=visitors earliest=-1mon@mon latest=@mon NOT [search source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name] &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;source=visitors earliest=-1mon@mon latest=@mon &lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I did a spot check for some of the results that show up. They exist in the June-aug range as well. &lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 16:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181885#M52419</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2014-10-28T16:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181886#M52420</link>
      <description>&lt;P&gt;You still haven't run the &lt;CODE&gt;format&lt;/CODE&gt; version of the subsearch, as listed above. What does it return?&lt;/P&gt;

&lt;P&gt;(Also, is the field name you're looking for really "name"? If not, what is it really?)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 16:26:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181886#M52420</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-28T16:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181887#M52421</link>
      <description>&lt;P&gt;Sorry, I wasn't explicit. I ran the query with format turned on as well.  If I run the inner query on its own, then it returns accurate data. &lt;/P&gt;

&lt;P&gt;However, in following syntax, it seems to have no bearing on the results. The following two queries return identical result (count, format, table, ...)&lt;/P&gt;

&lt;P&gt;source=visitors earliest=-1mon@mon latest=@mon NOT [search source=visitors earliest=-4mon@mon latest=-1mon@mon | table name | dedup name]&lt;/P&gt;

&lt;P&gt;source=visitors earliest=-1mon@mon latest=@mon&lt;/P&gt;

&lt;P&gt;The actual field is "Email Address". &lt;/P&gt;

&lt;P&gt;source=emailusers earliest=-1mon@mon latest=@mon NOT [search source=visitors earliest=-4mon@mon latest=-1mon@mon | table "Email Address" | dedup "Email Address"]&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2014 16:00:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181887#M52421</guid>
      <dc:creator>vjverma</dc:creator>
      <dc:date>2014-10-29T16:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find records that only exist in a particular time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181888#M52422</link>
      <description>&lt;P&gt;I hate to ask the "is it plugged in" question, but in that last search in your response with the "Email Address" field, you're not really passing &lt;CODE&gt;source=visitors&lt;/CODE&gt; in the subsearch, are you? If your real source is &lt;CODE&gt;emailusers&lt;/CODE&gt; then that needs to be &lt;CODE&gt;emailusers&lt;/CODE&gt; also.&lt;/P&gt;

&lt;P&gt;Assuming that's the case, it is possible that you could get the same response from your first and second searches if, in fact, every one of your visitors from September did not visit you between June and August. But you are asserting that there &lt;STRONG&gt;are&lt;/STRONG&gt; visitors from September that show up between June and August. I'm wondering if you aren't running into a subsearch limit problem...&lt;/P&gt;

&lt;P&gt;Given that I can't seem to come up with a way to make this work for you, you should try @somesoni2's answer below (with my suggested tweaks).&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2014 18:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-records-that-only-exist-in-a-particular-time-range/m-p/181888#M52422</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-10-29T18:14:57Z</dc:date>
    </item>
  </channel>
</rss>

