Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Submit a search job exec_mode = normal , asynchronous
*/
public static void asyncSearchJobExample() {
Service splunkService = connectAndLoginToSplunkExample();
OutputMode outputMode = OutputMode.JSON;// xml,json,csv
JobArgs queryArgs = new JobArgs();
queryArgs.setEarliestTime("-2d@d");
queryArgs.setLatestTime("now");
// submit the job
Job job = splunkService.getJobs().create("search index=_internal | head 5", queryArgs);
while (!job.isDone()) {
try {
Thread.sleep(500);
} catch (Exception e) {
}
}
JobResultsArgs outputArgs = new JobResultsArgs();
outputArgs.setOutputMode(outputMode);
InputStream stream = job.getResults(outputArgs);
processInputStream(stream, outputMode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.