<?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: Inner Join with subsearch using Splunk Python in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654374#M226099</link>
    <description>&lt;P&gt;Hi. Sorry I missed that you had passed in earliest and latest.&lt;/P&gt;&lt;P&gt;A few ideas&lt;/P&gt;&lt;P&gt;1) can you create a saved search and then run that. e.g.&amp;nbsp;savedsearch "mysavedsearch"&lt;/P&gt;&lt;P&gt;2) is the splunk search you are running with username and password got the permission to view the lookup table?&lt;/P&gt;&lt;P&gt;3) break down the search to find the issue e.g. maybe just run the inputlookup with a | stats count to make sure that part is working?&lt;/P&gt;&lt;P&gt;4) if you are an admin, you could look in the audit log to find out the number of results returning from your search&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2023 15:40:56 GMT</pubDate>
    <dc:creator>burwell</dc:creator>
    <dc:date>2023-08-15T15:40:56Z</dc:date>
    <item>
      <title>How to create Inner Join with subsearch using Splunk Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654305#M226090</link>
      <description>&lt;P&gt;I'm doing a main search of a sourcetype, then I need to join with a csv file using the inputlookup, both the main search and the subsearch have the `Name` column, but when sending the complete search through the api, it does not return the values correctly, but when I do the search manually in splunk it works correctly.&lt;/P&gt;
&lt;PRE&gt;import splunklib.client as client

service = client.connect(host=host, port=port, username=user, password=password)

search = '''search''' +  '''index="aiops_main" sourcetype="scom_np" OR sourcetype="scom_p" type="*SQL*" AND (type="*AlwaysOn*" OR type="*Server Service Stopped*")
| join type=left Name
    [| inputlookup maintenance_window.csv max=0
    | eval Name=lower(Name)
    | table Name, maint_down_start_time, maint_down_end_time, change_ticket]
| eval is_maintenance = if((alwayson_failovertime &amp;gt;= maint_down_start_time) AND alwayson_failovertime &amp;lt; maint_down_end_time,"true","false")
| table Name, type, is_maintenance
'''

kwargs_export = {
    "earliest_time": '1',
    "latest_time": "now",
    "search_mode": "normal",
    "exec_mode": "blocking",
}

# Create job and return results
try:
    job = service.jobs.create(search, parse_only=False, **kwargs_export)
    print(time.strftime('\n%Y_%m_%d__%H:%M:%S'))
    print("...done!")

except Exception as e:
    print("Trouble connecting to Splunk. Try again in a few seconds")
    raise e&lt;/PRE&gt;
&lt;P&gt;This error appears: "INFO: [subsearch]: Your timerange was substituted based on your search string"&lt;/P&gt;
&lt;P&gt;In short: the is_maintenance field when run manually in Splunk returns some lines as True, while running the same search in python returns all as False.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 19:42:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654305#M226090</guid>
      <dc:creator>RBolconte</dc:creator>
      <dc:date>2023-08-15T19:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654310#M226092</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; So when you test you are specifying a time range, I assume (not all time).&lt;/P&gt;&lt;P&gt;But for the python api search if you don't pass in earliest and latest, wouldn't it do an all time search?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 20:31:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654310#M226092</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2023-08-14T20:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654368#M226097</link>
      <description>&lt;P&gt;If I take the earliest_time and latest_time from kwargs_export, it remains the same, without joining the information from maintenance_window.csv&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 13:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654368#M226097</guid>
      <dc:creator>RBolconte</dc:creator>
      <dc:date>2023-08-15T13:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654374#M226099</link>
      <description>&lt;P&gt;Hi. Sorry I missed that you had passed in earliest and latest.&lt;/P&gt;&lt;P&gt;A few ideas&lt;/P&gt;&lt;P&gt;1) can you create a saved search and then run that. e.g.&amp;nbsp;savedsearch "mysavedsearch"&lt;/P&gt;&lt;P&gt;2) is the splunk search you are running with username and password got the permission to view the lookup table?&lt;/P&gt;&lt;P&gt;3) break down the search to find the issue e.g. maybe just run the inputlookup with a | stats count to make sure that part is working?&lt;/P&gt;&lt;P&gt;4) if you are an admin, you could look in the audit log to find out the number of results returning from your search&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 15:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654374#M226099</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2023-08-15T15:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654392#M226108</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I just ran the csv search and it actually returned nothing (Splunk API):&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;| inputlookup maintenance_window.csv max=0
    | eval Name=lower(Name)
    | table Name, maint_down_start_time, maint_down_end_time, change_ticket&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;However, in splunk I can return the values through manual search, that is, the user has access to the search.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Can you tell if it's something from the api?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 18:28:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654392#M226108</guid>
      <dc:creator>RBolconte</dc:creator>
      <dc:date>2023-08-15T18:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654398#M226110</link>
      <description>&lt;P&gt;Maybe the inputlookup is restricted to permission in a given app. You are using that app in your splunk search via the web.&lt;/P&gt;&lt;P&gt;The api is running the search app? Just an idea.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 19:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654398#M226110</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2023-08-15T19:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654399#M226111</link>
      <description>&lt;P&gt;If I try searching for a lookup that can't be found I get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR SearchMessages - orig_component="SearchOperator:inputcsv" app="search" sid="1692127130.1422" message_key="INPUT_CSV:INVALID_LOOKUP_TABLE_TYPE" message=The lookup table 'maintenance_window.csv' requires a .csv or KV store lookup definition.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;this in /opt/splunk/var/log/splunk/search_messages.log&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 19:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654399#M226111</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2023-08-15T19:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654404#M226114</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;I ran it without the "search" at the beginning of the string just using the inputlookup and it worked, now I just need to understand how to make the inputlookup work as a subsearch, is it possible with savedsearch?&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;Not sure what this is, I'll look into it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 19:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654404#M226114</guid>
      <dc:creator>RBolconte</dc:creator>
      <dc:date>2023-08-15T19:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inner Join with subsearch using Splunk Python</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654412#M226115</link>
      <description>&lt;P&gt;Hi so why not just put the whole search as a saved search: the search part with the subsearch. It is simpler.&lt;/P&gt;&lt;P&gt;Then run the saved search as i suggested&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| savedsearch "mysaved_search_name"&lt;/LI-CODE&gt;&lt;P&gt;Don't put search at the beginning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 21:37:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-Inner-Join-with-subsearch-using-Splunk-Python/m-p/654412#M226115</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2023-08-15T21:37:10Z</dc:date>
    </item>
  </channel>
</rss>

