Splunk Search

Search on Java SDK, can get whole data

BenisLion
Engager

Hi, I am new to Splunk, And I'm trying to get the latest 6 months's data(about 11,000 datas), and store into Mongo db.
I've tried example codes. However, I find everytime I can only get about 1500 datas. I don't know why.
There's my codes.

public ResultsReaderJson getDataFromSplunk() {
    // Create a simple search job
    String searchquery="search *";
    Job job = conn.getService().getJobs().create(searchQuery);
    // Wait for the job to finish
    while (!job.isDone()) {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    // Specify JSON as the output mode for results
    JobResultsArgs resultsArgs = new JobResultsArgs();
    resultsArgs.setOutputMode(JobResultsArgs.OutputMode.JSON);

    // Display results in JSON using ResultsReaderJson
    InputStream jobResults = job.getResults(resultsArgs);
    ResultsReaderJson results = null;
    try {
        results = new ResultsReaderJson(jobResults);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return results;
}

I can't solve this problem by myself, and so I really need help. Thank you!

Tags (2)
0 Karma
1 Solution

Damien_Dallimor
Ultra Champion

Damien_Dallimor
Ultra Champion

Look at this example for performing an export.

http://dev.splunk.com/view/SP-CAAAEHQ#exportjob

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...