<?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 getting no results returned using the Splunk Python SDK to search our Splunk instance? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277908#M83859</link>
    <description>&lt;P&gt;I'm still getting 0 as the output. Could there be something wrong in my query itself?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2016 17:40:59 GMT</pubDate>
    <dc:creator>rchoul</dc:creator>
    <dc:date>2016-09-16T17:40:59Z</dc:date>
    <item>
      <title>Why am I getting no results returned using the Splunk Python SDK to search our Splunk instance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277906#M83857</link>
      <description>&lt;P&gt;I'm using the Splunk Python SDK search our Splunk instance. However, I'm not getting any results. &lt;/P&gt;

&lt;P&gt;Below is the code I'm using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys
from time import sleep
import splunklib.client as client
import splunklib.results as results

count=0

HOST = "abc"
PORT = 8089
USERNAME = "user"
PASSWORD = "password"

service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD)

search_query = "search * | head 10"
kwargs_normalsearch = {"exec_mode": "normal"}

job = service.jobs.create(search_query, **kwargs_normalsearch)

while True:
    while not job.is_ready():
        pass
    stats = {"isDone": job["isDone"],
             "doneProgress": float(job["doneProgress"])*100,
              "scanCount": int(job["scanCount"]),
              "eventCount": int(job["eventCount"]),
              "resultCount": int(job["resultCount"])}

status = ("\r%(doneProgress)03.1f%%   %(scanCount)d scanned   "
          "%(eventCount)d matched   %(resultCount)d results") % stats

sys.stdout.write(status)
sys.stdout.flush()
if stats["isDone"] == "1":
    sys.stdout.write("\n\nDone!\n\n")
    break
sleep(2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The connection is successful and I'm able to retrieve the list of apps but when I query it doesn't return any result. In fact, it says no result found. Below is the output I see when I run the query.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Connected Successfully&lt;/P&gt;

&lt;P&gt;0.0%   0 scanned   0 matched   0 results&lt;BR /&gt;
100.0%   0 scanned   0 matched   0 results&lt;/P&gt;

&lt;P&gt;Done!&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;When I run this query i.e. 'search *' in the Web UI I do get results. I'm learning to use splunk and its python SDK  so any help is immensely appreciated. &lt;/P&gt;

&lt;P&gt;Thank you,&lt;BR /&gt;
Regards&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 19:26:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277906#M83857</guid>
      <dc:creator>rchoul</dc:creator>
      <dc:date>2016-09-14T19:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting no results returned using the Splunk Python SDK to search our Splunk instance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277907#M83858</link>
      <description>&lt;P&gt;This works for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;while True:
    job.refresh()
    if job["isDone"] == "1":
        print job["eventCount"]
        break
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Sep 2016 17:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277907#M83858</guid>
      <dc:creator>thomrs</dc:creator>
      <dc:date>2016-09-16T17:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting no results returned using the Splunk Python SDK to search our Splunk instance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277908#M83859</link>
      <description>&lt;P&gt;I'm still getting 0 as the output. Could there be something wrong in my query itself?&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 17:40:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277908#M83859</guid>
      <dc:creator>rchoul</dc:creator>
      <dc:date>2016-09-16T17:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting no results returned using the Splunk Python SDK to search our Splunk instance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277909#M83860</link>
      <description>&lt;P&gt;Search looks right, if you add &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;print job["sid"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can get the job id and look it up under activity -&amp;gt; jobs.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 18:09:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-no-results-returned-using-the-Splunk-Python-SDK/m-p/277909#M83860</guid>
      <dc:creator>thomrs</dc:creator>
      <dc:date>2016-09-16T18:09:36Z</dc:date>
    </item>
  </channel>
</rss>

