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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...