I'm new to splunk and am facing an issue when doing a search using Java SDK. I have a search that should return around 300 rows but only 200 are returned and then an exception is thrown.
[Fatal Error] :-1:-1: Premature end of file.
com.splunk.HttpException: HTTP 401
When I run the same search in splunk UI, I get all the 300 + rows. Below is the code snippet that I use. Is there any configuration that I should change or is there anything wrong with this code? I also see the following error in logs.
Any help to help me resolve this issue is greatly appreciated.
service.login();
Job job = service.getJobs().create(splunkSearch.toString());
while (!job.isDone()) {
Thread.sleep(Integer.parseInt(sleepTime));
}
JobResultsArgs resultsArgs = new JobResultsArgs();
resultsArgs.setOutputMode(JobResultsArgs.OutputMode.JSON);
InputStream results = job.getResults(resultsArgs);
ResultsReaderJson resultsReader = new ResultsReaderJson(results);
HashMap<String, String> event;
while ((event = resultsReader.getNextEvent()) != null) {
System.out.println("***** Start of a row *****");
for (String key : event.keySet()) {
System.out.println(" "+key + ": " + event.get(key));
}
}
resultsReader.close();
... View more