<?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: Using field option in join command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448219#M126997</link>
    <description>&lt;P&gt;Could you please explain your goal here? What you have and what you want to achieve?&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2019 11:31:42 GMT</pubDate>
    <dc:creator>VatsalJagani</dc:creator>
    <dc:date>2019-06-25T11:31:42Z</dc:date>
    <item>
      <title>Using field option in join command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448218#M126996</link>
      <description>&lt;P&gt;If I get a search like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" ~~~~~ | table _time value code | join type=outer [search index="main" ~~~~  | table _time value]
| table _time value code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should I fill in the fields(_time, value) like this,  &lt;CODE&gt;| join type=outer _time value [~~]&lt;/CODE&gt;.&lt;BR /&gt;
I know if the field option is blank, all of the main and sub-search result fields join, is it right?&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 08:47:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448218#M126996</guid>
      <dc:creator>tkdguq0110</dc:creator>
      <dc:date>2019-06-25T08:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using field option in join command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448219#M126997</link>
      <description>&lt;P&gt;Could you please explain your goal here? What you have and what you want to achieve?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 11:31:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448219#M126997</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-06-25T11:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using field option in join command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448220#M126998</link>
      <description>&lt;P&gt;The field(s) to use in the &lt;CODE&gt;join&lt;/CODE&gt; are those that are present in both sides of the join and tell Splunk which events on each side are related.  For example, &lt;CODE&gt;join type=outer system [...]&lt;/CODE&gt; will combine events with the same system name.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448220#M126998</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-06-25T12:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using field option in join command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448221#M126999</link>
      <description>&lt;P&gt;You didn't supply a "what I hope to get out of this" for the code you posted, so it's hard to be sure about an answer.&lt;/P&gt;

&lt;P&gt;One thing I can say is that I see no reason to do a join.  The &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Join"&gt;fine documentation&lt;/A&gt; does everything it can to steer you away from join, because it's very likely the single worst performing command in Splunk.  &lt;/P&gt;

&lt;P&gt;A better option in this case  (there's actually several  - this isn't the only way by ANY stretch of the imagination!) might be to use &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Append"&gt;append&lt;/A&gt;...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" ... | table _time value code | append [search index="main" ... | table _time value] | table _time value code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But there's a lot more that could be done.&lt;/P&gt;

&lt;P&gt;There's no need to &lt;CODE&gt;table&lt;/CODE&gt; it three times, all that could be simplified to&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" ... | append [search index="main" ... ] | table _time value code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But even more importantly, what are we even doing?  If it's trying to blend together two "sets" of data, the Splunk way is to just dump them all into a big pile and &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Stats"&gt;stats&lt;/A&gt; them into behaving - if a stats is even necessary!&lt;/P&gt;

&lt;P&gt;Try running this and just see what it is you get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" (...) OR (...) | table _time value code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the &lt;CODE&gt;(...) OR (...)&lt;/CODE&gt; is &lt;EM&gt;both&lt;/EM&gt; of your criteria. You may need additional parentheses, for good form I'd go with &lt;CODE&gt;((...) OR (...))&lt;/CODE&gt;, but it seemed more clear to write it the other  way &lt;EM&gt;as an example&lt;/EM&gt;.&lt;/P&gt;

&lt;P&gt;If that's got duplication, then use stats to fix that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" (...) OR (...) | stats count by value code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you don't like the count in there, remove it with the &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/SearchReference/Fields"&gt;fields&lt;/A&gt; command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" (...) OR (...) | stats count by value code | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway, I hope this helps.  The resulting search - whatever it is that you come up with - will be undeniably better if it is even &lt;EM&gt;possible&lt;/EM&gt; to avoid join and you do avoid it.  There precious few times when a join is unavoidable.   For instance, I've been doing this since 2014 on complicated data sets and haven't used join even once (well, except in training, and as a few tests once).  And I'm originally from a SQL background!&lt;/P&gt;

&lt;P&gt;Happy Splunking,&lt;BR /&gt;
Rich&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 12:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-field-option-in-join-command/m-p/448221#M126999</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2019-06-25T12:43:03Z</dc:date>
    </item>
  </channel>
</rss>

