<?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: How to avoid subsearch auto-finalize in query performing outer join against lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160554#M45382</link>
    <description>&lt;P&gt;Ah, didn't think of trying metadata or inputlookup as first element of a sub-query. This certainly opens up possibilities!&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2013 16:46:42 GMT</pubDate>
    <dc:creator>tpflicke</dc:creator>
    <dc:date>2013-11-29T16:46:42Z</dc:date>
    <item>
      <title>How to avoid subsearch auto-finalize in query performing outer join against lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160552#M45380</link>
      <description>&lt;P&gt;I've got an inventory list, which greatly simplified looks like below and made it available to splunk as a lookup table.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host,os_type
m00001,linux
m00002,linux
m00003,linux
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want to do is list the number of records against the inventory, including where the count is 0.&lt;BR /&gt;
The query below uses an outer join and works but for anything longer than a few minutes I get &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[subsearch]: Search auto-finalized after time limit (60 seconds) reached.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To be of value the count, i.e. inner query, would need to run for relatively long periods, say 1 day.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup server_list
| fields host  
| join type=outer host [ search index=some_index | stats count by host ]
| fillnull value=0 count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I pondered using metadata but both metadata and inputlookup need to be the first command so that seems to be a non-starter.&lt;/P&gt;

&lt;P&gt;I can use the REST API and get the desired result by effectively doing the outer join outside Splunk but I wonder what other options exist.&lt;BR /&gt;
I am probably not able to increase the subquery auto-finalize limit.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2013 14:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160552#M45380</guid>
      <dc:creator>tpflicke</dc:creator>
      <dc:date>2013-11-29T14:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid subsearch auto-finalize in query performing outer join against lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160553#M45381</link>
      <description>&lt;P&gt;I have the similar setup (server name inventory) and below query works for me just fine using metadata. (you need to add a '|' before metadata to make is first command)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup serverInventory.csv | fields serverName | rename serverName as host | join type=outer host [|metadata type=hosts index=some_index | table host, totalCount]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2013 16:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160553#M45381</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-29T16:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid subsearch auto-finalize in query performing outer join against lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160554#M45382</link>
      <description>&lt;P&gt;Ah, didn't think of trying metadata or inputlookup as first element of a sub-query. This certainly opens up possibilities!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2013 16:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160554#M45382</guid>
      <dc:creator>tpflicke</dc:creator>
      <dc:date>2013-11-29T16:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid subsearch auto-finalize in query performing outer join against lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160555#M45383</link>
      <description>&lt;P&gt;There are a couple of ways. First, another answer has suggested using the &lt;CODE&gt;metadata&lt;/CODE&gt; command, which is fine as long are you're just counting by host. If you're needing a more specific query, a count by host+source, or something else, that won't help you (though in version 6.0 you can doing things like &lt;CODE&gt;| tstats count WHERE source=xyz GROUPBY host,source&lt;/CODE&gt; very quickly using any other indexed field, or you can similarly use an accelerated data model for more complex queries).&lt;/P&gt;

&lt;P&gt;But I would say that you can just reverse the order in general:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x somekeywords | stats count by host | join host [ inputlookup server_list ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This misses out any empty hosts, so you won't have zeros, though there are workarounds to this, like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x somekeywords | append [ inputlookup server_list ] | stats count by host | eval count=count-1 | join host [ inputlookup server_list ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is really what you want, not to run the main search in a subsearch.&lt;/P&gt;

&lt;P&gt;But really, the better answer for the functionality you want is simply a lookup, which you can configure as an auto lookup (see props.conf and transforms.conf) or inline:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x somekeywords | stats count by host | lookup server_list host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x somekeywords | append [ inputlookup server_list ] | stats count by host | eval count=count-1 | lookup server_list host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2013 20:26:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-avoid-subsearch-auto-finalize-in-query-performing-outer/m-p/160555#M45383</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2013-11-29T20:26:38Z</dc:date>
    </item>
  </channel>
</rss>

