<?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 do I export a large dataset from the REST API? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448841#M78007</link>
    <description>&lt;P&gt;It seems that the export API endpoint streams results instead of saving them and so allows you to have much larger result sets. &lt;/P&gt;

&lt;P&gt;The answer to the question is, therefore, not to use the /jobs/search endpoint to create a search job and then later go fetch the results. Instead, use export to stream it all over the wire.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Oct 2018 19:43:11 GMT</pubDate>
    <dc:creator>andrewbeak</dc:creator>
    <dc:date>2018-10-29T19:43:11Z</dc:date>
    <item>
      <title>How do I export a large dataset from the REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448840#M78006</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm reading the documentation at &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.2.0/RESTREF/RESTsearch#search.2Fjobs"&gt;http://docs.splunk.com/Documentation/Splunk/7.2.0/RESTREF/RESTsearch#search.2Fjobs&lt;/A&gt; but I'm having problems getting all the search results that I need.&lt;/P&gt;

&lt;P&gt;The logic that I thought would work is:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Create an asynchronous search job&lt;/LI&gt;
&lt;LI&gt;Regularly poll the job until it is done&lt;/LI&gt;
&lt;LI&gt;Fetch the resultCount from the job&lt;/LI&gt;
&lt;LI&gt;Fetch paginated results &lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I believe that there is some setting in limits.conf that restricts how many results you can pull at a time.  By default, it's set to 50k and I'm using Splunk Cloud, so I can't touch this.  That's why I'm fetching pages of results.&lt;/P&gt;

&lt;P&gt;However, no matter what I set max_count to in the search request, Splunk normalizes this request to 1000.  When I call the API to get the number of results in the data-set, it says that there are 1000.&lt;/P&gt;

&lt;P&gt;Here is a screenshot from inspecting the job:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5996i99ECB3044A6157E5/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;What is the best way to use the API to get a large dataset out of Splunk?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 18:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448840#M78006</guid>
      <dc:creator>andrewbeak</dc:creator>
      <dc:date>2018-10-29T18:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a large dataset from the REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448841#M78007</link>
      <description>&lt;P&gt;It seems that the export API endpoint streams results instead of saving them and so allows you to have much larger result sets. &lt;/P&gt;

&lt;P&gt;The answer to the question is, therefore, not to use the /jobs/search endpoint to create a search job and then later go fetch the results. Instead, use export to stream it all over the wire.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 19:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448841#M78007</guid>
      <dc:creator>andrewbeak</dc:creator>
      <dc:date>2018-10-29T19:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a large dataset from the REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448842#M78008</link>
      <description>&lt;P&gt;The easiest way to export is in my opinion to do it via &lt;CODE&gt;curl&lt;/CODE&gt;. E.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u USERNAME:PASSWORD &lt;A href="https://SPLUNK_URL:8089/services/search/jobs/export" target="test_blank"&gt;https://SPLUNK_URL:8089/services/search/jobs/export&lt;/A&gt; \
        --data-urlencode search='search index="my-index" earliest=0 latest=now | table field1, field2' \
        -d output_mode=csv \
        -d earliest_time='-y@y' \
        -d latest_time='@y' \
        -o output-file.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this case from the previous year into the file &lt;CODE&gt;output-file.csv&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 14:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448842#M78008</guid>
      <dc:creator>happycoding</dc:creator>
      <dc:date>2019-01-21T14:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a large dataset from the REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448843#M78009</link>
      <description>&lt;P&gt;Andrew, we're getting XML parse errors from the jobs.export API over python SDK, whereas jobs.oneshot completes the same query (albeit too slow for our application). Is there an alternative, fast method to export  query results as a single XML or json file perhaps? &lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 15:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448843#M78009</guid>
      <dc:creator>alancalvitti</dc:creator>
      <dc:date>2020-01-17T15:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a large dataset from the REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448844#M78010</link>
      <description>&lt;P&gt;heres my powershell way of getting large results through rest &lt;/P&gt;

&lt;P&gt;&lt;A href="https://github.com/dstaulcu/SplunkTools/blob/master/Splunk-SearchLargeJobs-Example.ps1"&gt;https://github.com/dstaulcu/SplunkTools/blob/master/Splunk-SearchLargeJobs-Example.ps1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 06:36:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-export-a-large-dataset-from-the-REST-API/m-p/448844#M78010</guid>
      <dc:creator>dstaulcu</dc:creator>
      <dc:date>2020-01-18T06:36:03Z</dc:date>
    </item>
  </channel>
</rss>

