<?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: Joining two log files that have a common field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83751#M21334</link>
    <description>&lt;P&gt;&lt;IMG src="http://" alt="alt text" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Nov 2014 05:02:59 GMT</pubDate>
    <dc:creator>karthicjayarama</dc:creator>
    <dc:date>2014-11-17T05:02:59Z</dc:date>
    <item>
      <title>Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83747#M21330</link>
      <description>&lt;P&gt;Hi All -&lt;/P&gt;

&lt;P&gt;I am pretty new at advanced splunk searching, so I'm probably missing something very easy.  I have two access log files that are of the same request, but from different servers, logging different things.  They share a common field that is unique per request.  I'd like to join these two files in a splunk search.  I've easily whipped up a search using join which seems to work, however the main search results screen only shows one of the two files as output.  I'd like to see a combination of both files instead.  Here are examples:&lt;/P&gt;

&lt;P&gt;file 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10.10.10.10 - - [04/Nov/2010:10:40:02 -0400] "GET /favicon.ico HTTP/1.1" 200 318 "-" AAABBBCCCDDDEEEFFF
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;file 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10.10.10.10 myusername AAABBBCCCDDDEEEFFF
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;AAABBBCCCDDDEEEFFF is unique, and common between the two.  I turned that into a field called UniqueID on both.  What I'm ultimately after is a single result that looks like (or something similar):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10.10.10.10 - - [04/Nov/2010:10:40:02 -0400] "GET /favicon.ico HTTP/1.1" 200 318 "-" AAABBBCCCDDDEEEFFF myusername
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The join I have come up with is simply:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_log_1" | join UniqueID [search sourcetype="access_log_2" ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I save these results a csv, it works as expected - however, I can't see the results layed out nicely in the splunk interface.  Am I missing something?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Al&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2010 21:46:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83747#M21330</guid>
      <dc:creator>Al</dc:creator>
      <dc:date>2010-11-04T21:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83748#M21331</link>
      <description>&lt;P&gt;You dont really want to use join in this case.   Join is the most intuitive direction to go in, but it's not very efficient and it's pretty cumbersome. &lt;/P&gt;

&lt;P&gt;there are two other ways to do it that are usually better -- &lt;CODE&gt;transaction&lt;/CODE&gt; and &lt;CODE&gt;stats&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;1) Stats.   Im not sure what you're looking to do, but here's a made-up example showing the basic idea: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="access_log_1" OR search sourcetype="access_log_2" | stats first(someField) first(someOtherField) sum(bytes) by UniqueID&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will allow you to merge the two rows into a single row and calculate statistics on the pairs.&lt;/P&gt;

&lt;P&gt;2) Transaction&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="access_log_1" OR search sourcetype="access_log_2" | transaction UniqueID&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This is a little different in how it does it, but similar.  transaction takes the two single line events and basically makes a single multiline event.   Any fields present on either event get carried over, (and where the field is present on both you will get multivalued fields in the process)&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2010 00:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83748#M21331</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-11-05T00:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83749#M21332</link>
      <description>&lt;P&gt;Hi nick,&lt;/P&gt;

&lt;P&gt;transaction is perfect.  Thank you very much.&lt;/P&gt;

&lt;P&gt;Al&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2010 20:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83749#M21332</guid>
      <dc:creator>Al</dc:creator>
      <dc:date>2010-11-05T20:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83750#M21333</link>
      <description>&lt;P&gt;Just a note - but often after a few more days of headscratching people come back to stats.  It's the least intuitive but generally performs the best.  Once you get used to it it starts to feel simpler than transaction.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2010 23:54:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83750#M21333</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-11-05T23:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83751#M21334</link>
      <description>&lt;P&gt;&lt;IMG src="http://" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2014 05:02:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83751#M21334</guid>
      <dc:creator>karthicjayarama</dc:creator>
      <dc:date>2014-11-17T05:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Joining two log files that have a common field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83752#M21335</link>
      <description>&lt;P&gt;The results seems to be outer join of SQL. It works perfectly. Thank you~&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 02:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Joining-two-log-files-that-have-a-common-field/m-p/83752#M21335</guid>
      <dc:creator>loopbit</dc:creator>
      <dc:date>2016-03-17T02:57:26Z</dc:date>
    </item>
  </channel>
</rss>

