Reporting

How to send a Unix time as the value for earliest and latest parameters to a saved search using java API?

kicksammy
Explorer

i am trying to send Unix time to a saved search and i m expecting the Splunk to return the events for the Unix time earliest and latest. Below is the code i'm using.
But Splunk runs query for All Time.
How can I send a Unix time as the value for earliest and latest parameters

    ServiceArgs namespace = new ServiceArgs();
    namespace.setApp(appName);
    SavedSearch savedSearch = service.getSavedSearches(namespace).get(searchName);

    log.debug("Run the '" + savedSearch.getName() + "' search ("
            + savedSearch.getSearch() + ")\n");
    Job jobSavedSearch = null;
    SavedSearchDispatchArgs dispatchArgs = new SavedSearchDispatchArgs();
    //// These attributes have setter methods
    dispatchArgs.setDispatchEarliestTime("1405616400");
    dispatchArgs.setDispatchLatestTime("1405620000");
    //       Run the saved search
    try {
        jobSavedSearch = savedSearch.dispatch(dispatchArgs);
    } catch (InterruptedException e1) {
        log.fatal("Splunk serach job interrupted", e1);

    }
Tags (4)
0 Karma

somesoni2
Revered Legend

Try setting "DispatchTimeFormat" property to "%s" in the dispatchArgs object.

..
..
dispatchArgs.setDispatchEarliestTime("1405616400");
dispatchArgs.setDispatchLatestTime("1405620000");
//Add this
dispatchArgs.setDispatchTimeFormat("%s");
..
..
0 Karma
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 ...