<?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: help on subsearch which works randomly in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487478#M193845</link>
    <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
if you want to filter results, add it as subsearch in the main search or in another one search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ...
| search Country=* [ | inputlookup host.csv | table host ] 
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if instead you need some additional field in your lookup, add it at the end of the search before the table command, using the lookup command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | ...
   | search Country=* 
   | lookup host.csv host OUTPUT your_additional_fields
   | rename host as Hostname 
   | table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
   | sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2019 08:10:18 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-11-21T08:10:18Z</dc:date>
    <item>
      <title>help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487469#M193836</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I use the search below&lt;BR /&gt;
what is strange is that sometimes it works fine and five minutes ago I can retrieve the fields "Geoloc" which is build after the join &lt;BR /&gt;
I tried to modify the type (outer or left) but it continue to works randomly&lt;BR /&gt;
what is the problem please???&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| inputlookup host.csv 
    | table host] `disks` 
| fields Type Name TotalSpaceKB FreeSpaceKB host 
| eval time = strftime(_time, "%m/%d/%Y %H:%M") 
| eval FreeSpace = FreeSpaceKB/1024 
| eval FreeSpace = round(FreeSpace/1024,1) 
| eval TotalSpace = TotalSpaceKB/1024 
| eval TotalSpace = round(TotalSpace/1024,1) 
| lookup test.csv HOSTNAME as host output SITE DESCRIPTION_MODEL ROOM COUNTRY 
| stats latest(FreeSpace) as FreeSpace latest(TotalSpace) as TotalSpace values(DESCRIPTION_MODEL) as Model values(SITE) as Site values(COUNTRY) as Country by host 
| where FreeSpace &amp;lt;= 132 AND TotalSpace &amp;gt;= 64 
| eval FreeSpace=FreeSpace." GB", TotalSpace=TotalSpace." GB" 
| rename FreeSpace as "Free space", TotalSpace as "Total space" 
| search Country=France 
| join host type=outer 
    [| search `wire` 
    | fields USERNAME NAME AP_NAME Building 
    | rename USERNAME as host 
    | eval host=upper(host) 
    | lookup test2.csv NAME as AP_NAME OUTPUT Building 
    | eval Building=upper(Building) 
    | stats last(Building) as "Geoloc" by host ] 
| rename host as Hostname 
| table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
| sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 10:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487469#M193836</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-20T10:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487470#M193837</link>
      <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
you should check the number of results of you subsearch running it by itself, because there a limit of 50,000 results in subsearches.&lt;BR /&gt;
So you should try to build you search in a different way, putting the search (now in subsearch) as the main search and eventually inpulookup as subsearch.&lt;BR /&gt;
In addition remember that join isn't a performant command (Splunk isn't a DB) and it's prefereable to use other approaches as  stats and join command is to use only when you haven't other solutions.&lt;/P&gt;

&lt;P&gt;In other words, something like this (I cannot test it, but follow the approach):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`wire` 
| fields USERNAME NAME AP_NAME Building 
| rename USERNAME as host 
| eval host=upper(host) 
| lookup test2.csv NAME as AP_NAME OUTPUT Building 
| eval Building=upper(Building) 
| lookup host.csv host OUTPUT  Type Name TotalSpaceKB FreeSpaceKB
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 11:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487470#M193837</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-20T11:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487471#M193838</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
Yes I have more than  50,000 results in my subsearches&lt;BR /&gt;
Does it explains that I have results randomly?&lt;BR /&gt;
And concerning your proposal it means that I have to build my host.csv file automatically&lt;BR /&gt;
For different reasons I prefer to query the size disk directly in the index....&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 11:39:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487471#M193838</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-20T11:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487472#M193839</link>
      <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
it's random probably because not in all searches you have more than 50,000 results or there aren't relevant variations when subsearch exceeds 50,000 results.&lt;/P&gt;

&lt;P&gt;About the second point, in your search you use a lookup called host.csv as first command (inputlookup) in search, use it instead in subsearch or using the lookup command, not in main search.&lt;BR /&gt;
In other words, use in main search the search on index that has more than 50,000 results.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 11:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487472#M193839</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-20T11:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487473#M193840</link>
      <description>&lt;P&gt;for the testing I have deleted [| inputlookup host.csv &lt;BR /&gt;
     | table host] so it means that i run the search on random host&lt;BR /&gt;
and I have used the indexhat has more than 50,000 results in the min search but it changes nothing....&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 12:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487473#M193840</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-20T12:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487474#M193841</link>
      <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
as I said, the best way is to use a different approach, but for test try invert the searches: put the search on index in main search and inputlookup in subsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`wire` 
     | fields USERNAME NAME AP_NAME Building 
     | rename USERNAME as host 
     | eval host=upper(host) 
     | lookup test2.csv NAME as AP_NAME OUTPUT Building 
     | eval Building=upper(Building) 
     | stats last(Building) as "Geoloc" by host
 | join host 
     [ | inputlookup host.csv 
     | table host] `disks` 
 | fields Type Name TotalSpaceKB FreeSpaceKB host 
 | eval time = strftime(_time, "%m/%d/%Y %H:%M") 
 | eval FreeSpace = FreeSpaceKB/1024 
 | eval FreeSpace = round(FreeSpace/1024,1) 
 | eval TotalSpace = TotalSpaceKB/1024 
 | eval TotalSpace = round(TotalSpace/1024,1) 
 | lookup test.csv HOSTNAME as host output SITE DESCRIPTION_MODEL ROOM COUNTRY 
 | stats latest(FreeSpace) as FreeSpace latest(TotalSpace) as TotalSpace values(DESCRIPTION_MODEL) as Model values(SITE) as Site values(COUNTRY) as Country by host 
 | where FreeSpace &amp;lt;= 132 AND TotalSpace &amp;gt;= 64 
 | eval FreeSpace=FreeSpace." GB", TotalSpace=TotalSpace." GB" 
 | rename FreeSpace as "Free space", TotalSpace as "Total space" 
 | search Country=France 
 ] 
 | rename host as Hostname 
 | table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
 | sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 13:07:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487474#M193841</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-20T13:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487475#M193842</link>
      <description>&lt;P&gt;i done exactly what you said to me and i have the message "Error in 'join' command: Invalid join type"&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 13:21:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487475#M193842</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-20T13:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487476#M193843</link>
      <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
Sorry, there was a copy error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; `wire` 
      | fields USERNAME NAME AP_NAME Building 
      | rename USERNAME as host 
      | eval host=upper(host) 
      | lookup test2.csv NAME as AP_NAME OUTPUT Building 
      | eval Building=upper(Building) 
      | stats last(Building) as "Geoloc" by host
  | join host 
      [ | inputlookup host.csv 
      | table host `disks` 
  | fields Type Name TotalSpaceKB FreeSpaceKB host 
  | eval time = strftime(_time, "%m/%d/%Y %H:%M") 
  | eval FreeSpace = FreeSpaceKB/1024 
  | eval FreeSpace = round(FreeSpace/1024,1) 
  | eval TotalSpace = TotalSpaceKB/1024 
  | eval TotalSpace = round(TotalSpace/1024,1) 
  | lookup test.csv HOSTNAME as host output SITE DESCRIPTION_MODEL ROOM COUNTRY 
  | stats latest(FreeSpace) as FreeSpace latest(TotalSpace) as TotalSpace values(DESCRIPTION_MODEL) as Model values(SITE) as Site values(COUNTRY) as Country by host 
  | where FreeSpace &amp;lt;= 132 AND TotalSpace &amp;gt;= 64 
  | eval FreeSpace=FreeSpace." GB", TotalSpace=TotalSpace." GB" 
  | rename FreeSpace as "Free space", TotalSpace as "Total space" 
  | search Country=France 
  ] 
  | rename host as Hostname 
  | table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
  | sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 13:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487476#M193843</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-20T13:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487477#M193844</link>
      <description>&lt;P&gt;sorry giuseeppe but it always dosent works&lt;BR /&gt;
for summarize&lt;BR /&gt;
when I do the code below, it works&lt;BR /&gt;
but I have to integrate [ | inputlookup host.csv &lt;BR /&gt;
       | table host] somewhere....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`wire` 
| fields USERNAME NAME Building AP_NAME 
| rename USERNAME as host 
| eval host=upper(host) 
| lookup test2.csv NAME as AP_NAME OUTPUT Building 
| eval Building=upper(Building) 
| stats last(Building) as "Geoloc" by host 
| join host type=outer 
    [| search `diskspace` 
    | fields Type Name TotalSpaceKB FreeSpaceKB host 
    | eval time = strftime(_time, "%m/%d/%Y %H:%M") 
    | eval FreeSpace = FreeSpaceKB/1024 
    | eval FreeSpace = round(FreeSpace/1024,1) 
    | eval TotalSpace = TotalSpaceKB/1024 
    | eval TotalSpace = round(TotalSpace/1024,1) 
    | lookup lookup_cmdb_fo_all.csv HOSTNAME as host output DESCRIPTION_MODEL SITE COUNTRY 
    | stats latest(FreeSpace) as FreeSpace latest(TotalSpace) as TotalSpace last(DESCRIPTION_MODEL) as Model last(SITE) as Site last(COUNTRY) as Country by host ] 
| where FreeSpace &amp;lt;= 32 AND TotalSpace &amp;gt;= 64 
| eval FreeSpace=FreeSpace." GB", TotalSpace=TotalSpace." GB" 
| rename FreeSpace as "Free space", TotalSpace as "Total space" 
| search Country=* 
| rename host as Hostname 
| table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
| sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 13:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487477#M193844</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-20T13:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: help on subsearch which works randomly</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487478#M193845</link>
      <description>&lt;P&gt;Hi @jip31,&lt;BR /&gt;
if you want to filter results, add it as subsearch in the main search or in another one search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ...
| search Country=* [ | inputlookup host.csv | table host ] 
| ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if instead you need some additional field in your lookup, add it at the end of the search before the table command, using the lookup command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | ...
   | search Country=* 
   | lookup host.csv host OUTPUT your_additional_fields
   | rename host as Hostname 
   | table Hostname "Free space" "Total space" Model Site Country "Geoloc" 
   | sort +"Free space"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 08:10:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-subsearch-which-works-randomly/m-p/487478#M193845</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-21T08:10:18Z</dc:date>
    </item>
  </channel>
</rss>

