<?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: Find common entries in two different sources in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236935#M70420</link>
    <description>&lt;P&gt;I think (stress THINK) I may have found it by using a combination of everyone's answers.  This query seems to do the trick, thoughts?&lt;/P&gt;

&lt;P&gt;index=top10 source=/home/oracle/workdir/reboots_requests_summary.csv|dedup PREMISE|where RESULT_TIME!="" | join type=left PREMISE NOT [ search source=/home/oracle/workdir/reboots_summary.csv]|transaction PREMISE maxspan=1h|table PREMISE, RESULT_TIME,CREATION_DATE,_time|timechart count&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:06:16 GMT</pubDate>
    <dc:creator>dbcase</dc:creator>
    <dc:date>2020-09-29T10:06:16Z</dc:date>
    <item>
      <title>Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236929#M70414</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data that looks like this&lt;/P&gt;

&lt;P&gt;Source1&lt;BR /&gt;
PREMISE,CREATION_DATE,RESULT_TIME&lt;BR /&gt;
111111,20160621111111,20160621111211&lt;BR /&gt;
222222,20160622111111,20160622111211&lt;BR /&gt;
333333,20160622111111,20160622111211&lt;BR /&gt;
555555,20160522111111,20160622111211&lt;BR /&gt;
666666,20160522111111,20160622111211&lt;/P&gt;

&lt;P&gt;Source2&lt;BR /&gt;
PREMISE,CREATION_DATE,QUEUED_TIME&lt;BR /&gt;
111111,20160621111111,20160621111211&lt;BR /&gt;
222222,20160622111111,20160622111211&lt;BR /&gt;
333333,20160622111111,20160622111211&lt;BR /&gt;
122222,20160621111111,20160621111211&lt;BR /&gt;
233333,20160622111111,20160622111211&lt;BR /&gt;
344444,20160622111111,20160622111211&lt;/P&gt;

&lt;P&gt;I need to select the common values by PREMISE (meaning PREMISE needs to exist in BOTH files) so ideally I would end up with a table like this:&lt;BR /&gt;
PREMISE,CREATION_DATE&lt;BR /&gt;
111111,20160621111111&lt;BR /&gt;
222222,20160622111111&lt;BR /&gt;
333333,20160622111111&lt;/P&gt;

&lt;P&gt;Then I need to select the values by PREMISE that exist in Source1 but NOT in source two, so ideally I'd end up with this:&lt;/P&gt;

&lt;P&gt;PREMISE,CREATION_DATE&lt;BR /&gt;
555555,20160522111111&lt;BR /&gt;
666666,20160522111111&lt;/P&gt;

&lt;P&gt;I've tried several queries but no luck and now I'm going crosseyed.....&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:05:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236929#M70414</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236930#M70415</link>
      <description>&lt;P&gt;I'm assuming at this point you have a field called "Premise" in your events.  If you do not we can fix that, but it's not worth fixing unless it's a problem so just let us know.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  Also assuming that "Premise" will be unique.  E.g. that there is and will be only one Premise 555555 in either source.  Also, are date/time stamps working out OK on that data?&lt;/P&gt;

&lt;P&gt;Anyway, with those questions and caveats, the base search you can use for both answers is...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=source1 OR sourcetype=source2 | transaction maxspan=1h Premise
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then to see just the ones where it's in both tables, add to the end of that ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=source1 OR sourcetype=source2 | transaction maxspan=1h Premise | search eventcount&amp;gt;=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or for the ones in only one table...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=source1 OR sourcetype=source2 | transaction maxspan=1h Premise | search eventcount=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are more efficient ways to "put those together" than transaction (stats), but I think &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;transaction&lt;/A&gt; is easier and really not that bad in non-distributed environments.  You'll use &lt;CODE&gt;maxspan=X&lt;/CODE&gt; where X is as reasonably short of a time period as you can use that will still let it connect (keeps it efficient), so if source2's entry will always be within 5 minutes of source1's entry, then set a &lt;CODE&gt;maxspan=5m&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2016 12:13:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236930#M70415</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-07-02T12:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236931#M70416</link>
      <description>&lt;P&gt;You might be able to do this &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;join&lt;/A&gt;...&lt;/P&gt;

&lt;P&gt;This will do an inner join by default, so it should give you results where premise exists in both sources.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=source1  | join premise [source=source2] | table premise creation_date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then this will do a left join.  So it will keep everything from source1 and only those that match from source2.  So then you can keep only those that didn't match&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=source1 | join type=left premise [source=source2] | where isnull(queued_time) | table premise creation_date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if you wanted to see both results in one search, then maybe just modify the second search a bit&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=source1 | join type=left premise [source=source2] | eval matched = if(isnull(queued_time),"no","yes") | table premise creation_date matched
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jul 2016 21:50:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236931#M70416</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-07-03T21:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236932#M70417</link>
      <description>&lt;P&gt;Hmmmmm&lt;/P&gt;

&lt;P&gt;When I use this query that models after your first query, I get no results&lt;/P&gt;

&lt;P&gt;index=top10 source=/home/oracle/workdir/reboots_requests_summary.csv   | join PREMISE [search source=/home/oracle/workdir/reboots_summary.csv] |table PREMISE CREATION_DATE&lt;/P&gt;

&lt;P&gt;I had to add the [search in front of source to get it to not have an error.  Without adding [search splunk reported an unknown command.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:06:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236932#M70417</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236933#M70418</link>
      <description>&lt;P&gt;I like the eventcount trick!  That helped!  Is there anyway to see entries that are ONLY in source1 but not in Source2?   When I use the first query I end up with zero results, even though I know there are "matches"  (match= entry is in source1 but not in source 2)&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2016 17:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236933#M70418</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-07-05T17:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236934#M70419</link>
      <description>&lt;P&gt;Try this (add as many fields as you like and adjust where command as needed)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=source1 OR sourcetype=source2 | chart dc over premise by sourcetype | where source1=0 AND source2&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jul 2016 19:38:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236934#M70419</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-05T19:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236935#M70420</link>
      <description>&lt;P&gt;I think (stress THINK) I may have found it by using a combination of everyone's answers.  This query seems to do the trick, thoughts?&lt;/P&gt;

&lt;P&gt;index=top10 source=/home/oracle/workdir/reboots_requests_summary.csv|dedup PREMISE|where RESULT_TIME!="" | join type=left PREMISE NOT [ search source=/home/oracle/workdir/reboots_summary.csv]|transaction PREMISE maxspan=1h|table PREMISE, RESULT_TIME,CREATION_DATE,_time|timechart count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:06:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236935#M70420</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2020-09-29T10:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236936#M70421</link>
      <description>&lt;P&gt;Yes.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=source1 OR sourcetype=source2 | transaction maxspan=1h Premise | search eventcount=1 sourcetype=source1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You start out with either sourcetype, create the transaction on "Premise", then search for where there's only one event and it's with sourcetype source1.&lt;/P&gt;

&lt;P&gt;Let me know if that works.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2016 01:54:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236936#M70421</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-07-10T01:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find common entries in two different sources</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236937#M70422</link>
      <description>&lt;P&gt;Thanks Rich!!!&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jul 2016 01:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-common-entries-in-two-different-sources/m-p/236937#M70422</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-07-10T01:58:24Z</dc:date>
    </item>
  </channel>
</rss>

