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!

.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 ...