<?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: Why am I unable to filter a saved search using the Splunk Python SDK? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-am-I-unable-to-filter-a-saved-search-using-the-Splunk-Python/m-p/158276#M32084</link>
    <description>&lt;P&gt;For what I know, you can't postprocess a job in Python SDK. But you can perform the search itself:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client

sp_con = client.connect(username='admin', password='password', host='127.0.0.1', 
                        scheme='https', port='8089', app='appname', 
                        autologin=True)

query = """
| savedsearch "my_search" | 
search title="Elite Baller" person="me" | 
table *
"""

earliest = an_epoch_time
latest = an_epoch_time

rr = sp_con.jobs.oneshot(query, count=0, earliest_time=earliest, 
                         latest_time=latest)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember to give correct app and username to your connection, or your saved search will be not visible to the script.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2015 10:28:49 GMT</pubDate>
    <dc:creator>marco_sulla</dc:creator>
    <dc:date>2015-04-16T10:28:49Z</dc:date>
    <item>
      <title>Why am I unable to filter a saved search using the Splunk Python SDK?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-am-I-unable-to-filter-a-saved-search-using-the-Splunk-Python/m-p/158275#M32083</link>
      <description>&lt;P&gt;In the main Splunk interface, I can filter down on a saved search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| savedsearch "my_search" | search title="Elite Baller" person="me" | table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will run my saved search, "my_search", and then filter down the results further.&lt;/P&gt;

&lt;P&gt;I'm trying to do the same thing in the SDK (Python), using the same saved search. But it's not working for me! I've tried many iterations:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
# Load Saved Search
saved_search = self.connect().saved_searches['my_search']

# Load Job
if saved_search.history():
    job = saved_search.history()[-1]
else:
    job = saved_search.dispatch()

# Poll API
while True:
    job.refresh()

    if job['isDone'] == '1':
        break

# Here's where I'm trying to filter down the search further
search = ''

# search_items['title'] = 'Elite Baller'
# search_items['person'] = 'me'
if len(search_items) &amp;gt; 0:
    search += 'search '

    for key, val in iteritems(search_items):
        search += '%s%%3D%s ' % (key, val)

    search = search[:-1]    # trim trailing space

job_kwargs['search'] = search

# Fetch Result
job_result = job.results(**job_kwargs)
reader = results.ResultsReader(job_result)

# ... iterate over reader ... #
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway, I've tried every which way to build an argument list string and place it into job_kwargs, but no such luck.&lt;/P&gt;

&lt;P&gt;Am I missing something simple?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2015 23:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-am-I-unable-to-filter-a-saved-search-using-the-Splunk-Python/m-p/158275#M32083</guid>
      <dc:creator>photuris</dc:creator>
      <dc:date>2015-02-23T23:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I unable to filter a saved search using the Splunk Python SDK?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-am-I-unable-to-filter-a-saved-search-using-the-Splunk-Python/m-p/158276#M32084</link>
      <description>&lt;P&gt;For what I know, you can't postprocess a job in Python SDK. But you can perform the search itself:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client

sp_con = client.connect(username='admin', password='password', host='127.0.0.1', 
                        scheme='https', port='8089', app='appname', 
                        autologin=True)

query = """
| savedsearch "my_search" | 
search title="Elite Baller" person="me" | 
table *
"""

earliest = an_epoch_time
latest = an_epoch_time

rr = sp_con.jobs.oneshot(query, count=0, earliest_time=earliest, 
                         latest_time=latest)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember to give correct app and username to your connection, or your saved search will be not visible to the script.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 10:28:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-am-I-unable-to-filter-a-saved-search-using-the-Splunk-Python/m-p/158276#M32084</guid>
      <dc:creator>marco_sulla</dc:creator>
      <dc:date>2015-04-16T10:28:49Z</dc:date>
    </item>
  </channel>
</rss>

