<?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: Newbie: Splunk equivalent of NATURAL JOIN in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84608#M21568</link>
    <description>&lt;P&gt;Let's say that the events in A have sourcetype="A",  and the events in B have sourcetype="B".  Maybe in your actual data it'll be source or host or something else but it doesnt matter. &lt;/P&gt;

&lt;P&gt;1) If you're looking to stitch everything together on session ids, there are several ways to do this sort of thing.  Here are two&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(sourcetype=A) OR (sourcetype=B ipaddr=*) | transaction session | search http_status&amp;gt;=400&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and sometimes stats is the best tool for the job, although here you need a little mvexpand and it's a bit more complicated: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(sourcetype=A ) OR (sourcetype=B ipaddr=*) | stats count first(ipaddr) as ipaddr values(http_status) as http_status by session | mvexpand http_status | search http_status&amp;gt;=400 | fields ipaddr&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;2) However depending on how sparse the http_status values over 400 are,  you might want to take the approach of using a subsearch.  The following will use a subsearch to get all the session id's that had errors,  and then it searches on all of those session Id's against sourcetype B.  Then finally we just pipe to top to get the top  ipaddr values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=B ipaddr=* [sourcetype=A http_status&amp;gt;=400 | fields session] | top ipaddr
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Apr 2011 23:44:47 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2011-04-19T23:44:47Z</dc:date>
    <item>
      <title>Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84607#M21567</link>
      <description>&lt;P&gt;I don't really know what to search for on here, but I can't seem to get the | (pipe operator) to work like UNIX.&lt;/P&gt;

&lt;P&gt;I have two sets of records. Examples of each type:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;A) April 18, session=12345 http_status=404
   April 19, session=78912 http_status=200
   April 20, session=45678 http_status=503
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;B) April 18, session=12345 ipaddr=89.76.45.34
   April 19, session=78912 ipaddr=44.27.53.78
   April 20, session=45678 ipaddr=79.73.25.39
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's what I'm trying to get my query to do: get all session ids where http_status &amp;gt;= 400, and then give me the result set of logs where session = x, and ipaddr exists.&lt;/P&gt;

&lt;P&gt;Thank you! One example will open up a lot of doors for me with Splunk. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;UPDATED&lt;/STRONG&gt;: In SQL: SELECT * FROM "B" NATURAL JOIN "A"&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2011 23:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84607#M21567</guid>
      <dc:creator>travispowell</dc:creator>
      <dc:date>2011-04-19T23:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84608#M21568</link>
      <description>&lt;P&gt;Let's say that the events in A have sourcetype="A",  and the events in B have sourcetype="B".  Maybe in your actual data it'll be source or host or something else but it doesnt matter. &lt;/P&gt;

&lt;P&gt;1) If you're looking to stitch everything together on session ids, there are several ways to do this sort of thing.  Here are two&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(sourcetype=A) OR (sourcetype=B ipaddr=*) | transaction session | search http_status&amp;gt;=400&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and sometimes stats is the best tool for the job, although here you need a little mvexpand and it's a bit more complicated: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(sourcetype=A ) OR (sourcetype=B ipaddr=*) | stats count first(ipaddr) as ipaddr values(http_status) as http_status by session | mvexpand http_status | search http_status&amp;gt;=400 | fields ipaddr&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;2) However depending on how sparse the http_status values over 400 are,  you might want to take the approach of using a subsearch.  The following will use a subsearch to get all the session id's that had errors,  and then it searches on all of those session Id's against sourcetype B.  Then finally we just pipe to top to get the top  ipaddr values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=B ipaddr=* [sourcetype=A http_status&amp;gt;=400 | fields session] | top ipaddr
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Apr 2011 23:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84608#M21568</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-19T23:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84609#M21569</link>
      <description>&lt;P&gt;Let me explain better.&lt;/P&gt;

&lt;P&gt;The above example should return the first and last logs from B:&lt;/P&gt;

&lt;P&gt;April 18, session=12345 ipaddr=89.76.45.34&lt;BR /&gt;&lt;BR /&gt;
April 20, session=45678 ipaddr=79.73.25.39&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2011 23:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84609#M21569</guid>
      <dc:creator>travispowell</dc:creator>
      <dc:date>2011-04-19T23:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84610#M21570</link>
      <description>&lt;P&gt;because those are the two logs that have http_status &amp;gt;= 400 in log type A.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2011 23:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84610#M21570</guid>
      <dc:creator>travispowell</dc:creator>
      <dc:date>2011-04-19T23:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84611#M21571</link>
      <description>&lt;P&gt;I see.  sorry I misinterpreted yr question. See updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2011 23:52:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84611#M21571</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-19T23:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84612#M21572</link>
      <description>&lt;P&gt;No problem. Thanks for that. I updated my question so it's clearer for anyone else.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2011 00:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84612#M21572</guid>
      <dc:creator>travispowell</dc:creator>
      <dc:date>2011-04-20T00:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie: Splunk equivalent of NATURAL JOIN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84613#M21573</link>
      <description>&lt;P&gt;2 -- Stats worked the best &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2011 00:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Newbie-Splunk-equivalent-of-NATURAL-JOIN/m-p/84613#M21573</guid>
      <dc:creator>travispowell</dc:creator>
      <dc:date>2011-04-20T00:23:23Z</dc:date>
    </item>
  </channel>
</rss>

