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!

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

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...