<?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: query using join in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157736#M44433</link>
    <description>&lt;P&gt;so I changed it to source="/usr/local/nagios/var/nagios.log" earliest=-14days | [ search source="/opt/mysplunk.log" earliest=-14days "logid=store-stuff"  | eval storecode = substr(site,1,4) | top 3 storecode | return 3 storecode ]  &lt;/P&gt;

&lt;P&gt;I get "Subsearches are only valid as arguments to commands."  Perhaps i misunderstood your suggestion?&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2014 17:34:42 GMT</pubDate>
    <dc:creator>cevyn</dc:creator>
    <dc:date>2014-02-19T17:34:42Z</dc:date>
    <item>
      <title>query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157730#M44427</link>
      <description>&lt;P&gt;Trying to combine two logs .&lt;BR /&gt;
Using this query to get a list of items from user  log&lt;/P&gt;

&lt;P&gt;source="/opt/mysplunk.log" earliest=-14days "logid=store-stuff"  | eval storecode = substr(site,1,4) | top 3 storecode | FIELDS - count percent&lt;/P&gt;

&lt;P&gt;that gives me a short list of&lt;BR /&gt;
storecode&lt;/P&gt;

&lt;P&gt;1   1234&lt;/P&gt;

&lt;P&gt;2   6789&lt;/P&gt;

&lt;P&gt;And the                   | FIELDS – count percent                     removes those extra fields so I just get my entries of 1234 6789&lt;BR /&gt;
This also proves my substring is right because I’m catching the string I expect.&lt;BR /&gt;
Now I try to feed that into a network log to catch possible related causes that show up there &lt;/P&gt;

&lt;P&gt;source="/usr/local/nagios/var/nagios.log" earliest=-14days | join [ search source="/opt/mysplunk.log" earliest=-14days "logid=store-stuff"  | eval storecode = substr(site,1,4) | top 3 storecode | FIELDS - count percent]&lt;/P&gt;

&lt;P&gt;but the result seems to match 50k records that don’t have my identifiers of 1234 or 6789 in them .&lt;/P&gt;

&lt;P&gt;What am I doing wrong or what debugging method in splunk do I use to figure out what  it is really matching on?  What is it actually piping through?&lt;BR /&gt;
This is my first venture into join commands in splunk queries&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157730#M44427</guid>
      <dc:creator>cevyn</dc:creator>
      <dc:date>2014-02-19T16:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157731#M44428</link>
      <description>&lt;P&gt;You can see what is being returned if you use the search job inspector - it will have an entry like subsearch returned that should fill you in on what came through&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:40:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157731#M44428</guid>
      <dc:creator>dart</dc:creator>
      <dc:date>2014-02-19T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157732#M44429</link>
      <description>&lt;P&gt;Are you sure you're trying to perform a &lt;CODE&gt;join&lt;/CODE&gt;? Usually you have one (or more) join columns/fields and one (or more) other columns/fields that get added in the join... but your subsearch only yields one column.&lt;/P&gt;

&lt;P&gt;Maybe you're trying to filter the nagios source by results from the mysplunk source?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157732#M44429</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-19T16:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157733#M44430</link>
      <description>&lt;P&gt;does your source nagios.log have a field called storecode or your just want to do literal search for your storecode in the nagios.log events?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157733#M44430</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-02-19T16:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157734#M44431</link>
      <description>&lt;P&gt;So clearly your questions have revealed my limited splunk query experience.  The response that asked about literal search best understood my failings.  yes I want to go to nagios with the results of 1234 or 6789 in my example.  STORECODE was a literal I made up to capture the result of my substr.   Thanks for your persistence with my initial note.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 17:10:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157734#M44431</guid>
      <dc:creator>cevyn</dc:creator>
      <dc:date>2014-02-19T17:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157735#M44432</link>
      <description>&lt;P&gt;Based on your comment, here's how you generically search in source A based on the top three values of somefield from source B:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=A [search source=B | top 3 somefield | return 3 somefield]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Under the hood Splunk will first run the subsearch, translate the results to &lt;CODE&gt;((somefield="value1") OR (somefield="value2") OR (somefield="value3"))&lt;/CODE&gt;, and then run the main search with that filter added.&lt;/P&gt;

&lt;P&gt;If source A does not have a field called &lt;CODE&gt;somefield&lt;/CODE&gt; you can search its raw text by adding a dollar sign in the return command like so: &lt;CODE&gt;... | return 3 $somefield&lt;/CODE&gt;. If the field is called something else in source A you can rename it on the fly like so: &lt;CODE&gt;... | return 3 otherfield=somfield&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 17:16:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157735#M44432</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-19T17:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157736#M44433</link>
      <description>&lt;P&gt;so I changed it to source="/usr/local/nagios/var/nagios.log" earliest=-14days | [ search source="/opt/mysplunk.log" earliest=-14days "logid=store-stuff"  | eval storecode = substr(site,1,4) | top 3 storecode | return 3 storecode ]  &lt;/P&gt;

&lt;P&gt;I get "Subsearches are only valid as arguments to commands."  Perhaps i misunderstood your suggestion?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 17:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157736#M44433</guid>
      <dc:creator>cevyn</dc:creator>
      <dc:date>2014-02-19T17:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157737#M44434</link>
      <description>&lt;P&gt;Remove the pipe before the opening square bracket.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 18:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157737#M44434</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-19T18:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157738#M44435</link>
      <description>&lt;P&gt;You have been very generous.  My query is close but I get no results. If I look at the job inspect function and look at subsearch it shows storecode="1234"  when I think  want it to just be "1234"  (storecode being a variable I made up for the EVAL).    Sorry I'm spending a lot of time getting used to the syntax .  How do I drop the storecode=   out .&lt;BR /&gt;&lt;BR /&gt;
I tried things like value(storecode) but have obviously not found the right thing.  I feel like I'm trying to discuss philosophy in french and only have the vocabulary to say hello!  thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 19:53:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157738#M44435</guid>
      <dc:creator>cevyn</dc:creator>
      <dc:date>2014-02-19T19:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: query using join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157739#M44436</link>
      <description>&lt;P&gt;Like I said in the answer, put a dollar sign in front of the field in the return command like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | return 3 $otherfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will yield &lt;CODE&gt;(("value1") OR ("value2") OR ("value3"))&lt;/CODE&gt; as a filter for the main search.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 20:01:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-using-join/m-p/157739#M44436</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-02-19T20:01:21Z</dc:date>
    </item>
  </channel>
</rss>

