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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...