<?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 change service.jobs.oneshot to return unlimited number of rows in its result set? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185773#M53531</link>
    <description>&lt;P&gt;did you find a solution? Great if you can share it.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 13 Apr 2015 14:34:43 GMT</pubDate>
    <dc:creator>sramakr</dc:creator>
    <dc:date>2015-04-13T14:34:43Z</dc:date>
    <item>
      <title>How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185769#M53527</link>
      <description>&lt;P&gt;I have a Python script to run nightly and extract data using Splunk REST API.  Here is the code:&lt;/P&gt;

&lt;P&gt;kwargs_oneshot = {'latest_time': '2014-10-23T10:00:00.000',   'earliest_time': '2014-10-23T08:00:00.000', 'output_mode': 'csv'}&lt;BR /&gt;
searchquery_oneshot = 'search source=xyz event="watch" | table _time, event | sort - _time '&lt;BR /&gt;
oneshotsearch_results = service.jobs.oneshot(searchquery_oneshot, **kwargs_oneshot)&lt;BR /&gt;
f=open('myresults.csv', 'w')&lt;BR /&gt;
f.write(oneshotsearch_results.read())&lt;/P&gt;

&lt;P&gt;The resultset seem to have a limit of 100 records.  Is there anyway to set it to unlimited?  I don't see anything related to that on &lt;A href="http://docs.splunk.com/Documentation/PythonSDK/1.2.2/client.html" target="_blank"&gt;http://docs.splunk.com/Documentation/PythonSDK/1.2.2/client.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If not, how else I can make sure I retrieve the entire result set?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185769#M53527</guid>
      <dc:creator>fere</dc:creator>
      <dc:date>2020-09-28T18:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185770#M53528</link>
      <description>&lt;P&gt;sorry, codes lines in a readable format:&lt;/P&gt;

&lt;P&gt;kwargs_oneshot = {'latest_time': '2014-10-23T10:00:00.000', 'earliest_time': '2014-10-23T08:00:00.000', 'output_mode': 'csv'} &lt;/P&gt;

&lt;P&gt;searchquery_oneshot = 'search source=xyz event="watch" | table _time, event | sort - _time ' &lt;/P&gt;

&lt;P&gt;oneshotsearch_results = service.jobs.oneshot(searchquery_oneshot, **kwargs_oneshot) &lt;/P&gt;

&lt;P&gt;f=open('myresults.csv', 'w') &lt;/P&gt;

&lt;P&gt;f.write(oneshotsearch_results.read()) &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185770#M53528</guid>
      <dc:creator>fere</dc:creator>
      <dc:date>2020-09-28T18:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185771#M53529</link>
      <description>&lt;P&gt;I know adding 'count':0 lets the resultset to return 10000 entries.  However, I am lookign to export about 400000 records (or least 100000 entries on nightly basis).  What is the best way to do that?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2014 00:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185771#M53529</guid>
      <dc:creator>fere</dc:creator>
      <dc:date>2014-10-24T00:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185772#M53530</link>
      <description>&lt;P&gt;I changed the python script to do blocking, using pagination  example.  it goes through the loop and extracts 100 (my count size for testing it), but it still stops when the offset is 10000!  How can I make it receive 100s of 1000s of events?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2014 21:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185772#M53530</guid>
      <dc:creator>fere</dc:creator>
      <dc:date>2014-10-24T21:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185773#M53531</link>
      <description>&lt;P&gt;did you find a solution? Great if you can share it.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2015 14:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185773#M53531</guid>
      <dc:creator>sramakr</dc:creator>
      <dc:date>2015-04-13T14:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185774#M53532</link>
      <description>&lt;P&gt;Have you looked at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/Admin/Limitsconf"&gt;limits.conf&lt;/A&gt; spec? Seems to me you'll be hitting one if not many output limits here. Even if you adjust your limits.conf to allow more output, you'll still hit a ceiling, most certainly on sub searches.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 02:40:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185774#M53532</guid>
      <dc:creator>dolivasoh</dc:creator>
      <dc:date>2015-04-15T02:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185775#M53533</link>
      <description>&lt;H3&gt;SHORT ANSWER&lt;/H3&gt;

&lt;P&gt;You have to create a &lt;CODE&gt;$SPLUNK_HOME/etc/system/local/limits.conf&lt;/CODE&gt; file, add the stanza:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[restapi]
maxresultrows = 4294967295
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Furthermore you have to add &lt;CODE&gt;0&lt;/CODE&gt; to your &lt;CODE&gt;sort&lt;/CODE&gt; search command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query = """
search source=xyz event="watch" | 
table _time event | 
sort 0 - _time
"""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and run in your Python code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service.jobs.oneshot(query, count=0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H3&gt;LONG ANSWER&lt;/H3&gt;

&lt;P&gt;If you dig into the minimal and cryptic documentation:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/PythonSDK"&gt;http://docs.splunk.com/Documentation/PythonSDK&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;you can read for &lt;CODE&gt;job.oneshot()&lt;/CODE&gt; that &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;The oneshot method makes a single&lt;BR /&gt;
roundtrip to the server (as opposed to&lt;BR /&gt;
two for create() followed by&lt;BR /&gt;
results())&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;So &lt;CODE&gt;job.oneshot()&lt;/CODE&gt; is a &lt;CODE&gt;job.create()&lt;/CODE&gt; followed by a &lt;CODE&gt;job.results()&lt;/CODE&gt; (almost). So it can take the arguments of &lt;CODE&gt;create()&lt;/CODE&gt;:&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/SP-CAAAEE5#searchjobparams"&gt;http://dev.splunk.com/view/SP-CAAAEE5#searchjobparams&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;and the arguments of &lt;CODE&gt;results()&lt;/CODE&gt;:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Since Python SDK is a py wrapper around the REST API, you have also to specify an higher limit for it in limits.conf:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/Admin/Limitsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.3/Admin/Limitsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Note that I specified 2^32 - 1 in &lt;CODE&gt;maxresultrows&lt;/CODE&gt; because if you run this code on a 32 bit machine it hangs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;job = splunk_connection.jobs.create(search, max_count=2**32)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is probably caused by a C for loop.&lt;/P&gt;

&lt;P&gt;From &lt;CODE&gt;sort&lt;/CODE&gt; documentation:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;sort &lt;A href="&amp;lt;sort-by-clause&amp;gt;"&gt;&amp;lt;count&amp;gt;&lt;/A&gt;+ [desc] &lt;/P&gt;

&lt;P&gt;&amp;lt;count&amp;gt;&lt;BR /&gt;
Syntax: &amp;lt;int&amp;gt;&lt;BR /&gt;
Description: Specify the number of results to sort. If no count is&lt;BR /&gt;
specified, the default limit of 10000&lt;BR /&gt;
is used. If "0" is specified, all&lt;BR /&gt;
results will be returned&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Sort"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Sort&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 14:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185775#M53533</guid>
      <dc:creator>marco_sulla</dc:creator>
      <dc:date>2015-04-15T14:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185776#M53534</link>
      <description>&lt;P&gt;as I mentioned, I changed my code to using blocking and pagination.  The problem with stopping at 10000 was my oversight to forgetting to include 0 in the sort command. Adding 0 to sort command and looping  took care of getting all the results back from the search command. &lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2015 17:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185776#M53534</guid>
      <dc:creator>fere</dc:creator>
      <dc:date>2015-04-21T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to change service.jobs.oneshot to return unlimited number of rows in its result set?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185777#M53535</link>
      <description>&lt;P&gt;Really appreciated the depth and detail of this answer. It got our local dev environment working right searching and returning in minutes. &lt;/P&gt;

&lt;P&gt;Are there any ideas on if the API consumer doesn't have the ability to change the Splunk instance's maxresultsrow? The client/consumer we are building will deploy separate to customers who have Splunk and we won't have authority to make that change, just advise that it should be made. &lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 12:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-change-service-jobs-oneshot-to-return-unlimited-number-of/m-p/185777#M53535</guid>
      <dc:creator>nixonap</dc:creator>
      <dc:date>2019-05-20T12:40:20Z</dc:date>
    </item>
  </channel>
</rss>

