<?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 only getting a maximum of 100 events returned through a oneshot search via Java SDK? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207641#M60525</link>
    <description>&lt;P&gt;Using the Java SDK, you can pass a JobResultsArgs object to the Job's getResults() method.  Specify the count as 0 to return all available results, instead of just 100 (the default setting). &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;JobResultsArgs jobResultsArgs = new JobResultsArgs();
jobResultsArgs.setCount(0);
InputStream resultsNormalSearch = job.getResults(jobResultsArgs);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can use the ResultsReaderXml to iterate through all the available events. However, this is still limited to the server's default configuration setting of max 50,000, or whatever it's set to.&lt;/P&gt;

&lt;P&gt;For more info, see setCount method in JavaDocs for the Splunk SDK for Java:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/DocumentationStatic/JavaSDK/1.5.0/com/splunk/JobResultsArgs.html#setCount(int)"&gt;http://docs.splunk.com/DocumentationStatic/JavaSDK/1.5.0/com/splunk/JobResultsArgs.html#setCount(int)&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2016 00:08:36 GMT</pubDate>
    <dc:creator>TechDuke</dc:creator>
    <dc:date>2016-11-03T00:08:36Z</dc:date>
    <item>
      <title>Why am I only getting a maximum of 100 events returned through a oneshot search via Java SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207639#M60523</link>
      <description>&lt;P&gt;I'm using Splunk's Java SDK to get Splunk events, and the problem I'm facing is that Splunk only returns a maximum of 100 events, even if the search originally contains more than 100 events. How can I get all the events instead of just the 100 latest ones ?&lt;/P&gt;

&lt;P&gt;I'm calling a one-shot search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername(USERNAME_HERE);
loginArgs.setPassword(PASSWORD_HERE);
loginArgs.setHost(HOSTURL_HERE);
loginArgs.setPort(PORT_HERE);

HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
Service service = Service.connect(loginArgs);
String searchQuery_normal = SEARCH_STRING_HERE;
JobArgs jobargs = new JobArgs();
jobargs.setExecutionMode(JobArgs.ExecutionMode.BLOCKING);
Job job = service.getJobs().create(searchQuery_normal, jobargs);

//job only contains 100 events maximum
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Doing an online search revealed that doing this before calling the search might help, but it doesn't -- I still get only 100 of the newest events, not all:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;jobArgs.setAutoFinalizeEventCount(0);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Aug 2016 18:39:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207639#M60523</guid>
      <dc:creator>ahmadka2</dc:creator>
      <dc:date>2016-08-06T18:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I only getting a maximum of 100 events returned through a oneshot search via Java SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207640#M60524</link>
      <description>&lt;P&gt;Add &amp;amp;count=0 to your search uri.  It defaults to 100.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fresults&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 02:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207640#M60524</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-08T02:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I only getting a maximum of 100 events returned through a oneshot search via Java SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207641#M60525</link>
      <description>&lt;P&gt;Using the Java SDK, you can pass a JobResultsArgs object to the Job's getResults() method.  Specify the count as 0 to return all available results, instead of just 100 (the default setting). &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;JobResultsArgs jobResultsArgs = new JobResultsArgs();
jobResultsArgs.setCount(0);
InputStream resultsNormalSearch = job.getResults(jobResultsArgs);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can use the ResultsReaderXml to iterate through all the available events. However, this is still limited to the server's default configuration setting of max 50,000, or whatever it's set to.&lt;/P&gt;

&lt;P&gt;For more info, see setCount method in JavaDocs for the Splunk SDK for Java:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/DocumentationStatic/JavaSDK/1.5.0/com/splunk/JobResultsArgs.html#setCount(int)"&gt;http://docs.splunk.com/DocumentationStatic/JavaSDK/1.5.0/com/splunk/JobResultsArgs.html#setCount(int)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 00:08:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/207641#M60525</guid>
      <dc:creator>TechDuke</dc:creator>
      <dc:date>2016-11-03T00:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I only getting a maximum of 100 events returned through a oneshot search via Java SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/566061#M197242</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/181234"&gt;@ahmadka2&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/197927"&gt;@TechDuke&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/199197"&gt;@jkat54&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case even after setting the setCount to 0, I am unable to read it via&amp;nbsp;&lt;STRONG&gt;ResultsReaderJson&amp;nbsp;&lt;/STRONG&gt;(Is it again possible if&amp;nbsp;ResultsReaderJson reads only first 100 entries)&lt;/P&gt;&lt;P&gt;I have confirmed that stream contains all entries by printing it&lt;/P&gt;&lt;PRE&gt;String result = IOUtils.&lt;SPAN&gt;toString&lt;/SPAN&gt;(stream, StandardCharsets.&lt;SPAN&gt;UTF_8&lt;/SPAN&gt;);&lt;BR /&gt;System.&lt;SPAN&gt;out&lt;/SPAN&gt;.println(result);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 05:30:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-only-getting-a-maximum-of-100-events-returned-through-a/m-p/566061#M197242</guid>
      <dc:creator>raksh</dc:creator>
      <dc:date>2021-09-07T05:30:53Z</dc:date>
    </item>
  </channel>
</rss>

