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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...