Splunk Dev

Setting earliest_time through Java sdk

Hunterzz
New Member

i'm using Splunk java sdk to get search result. i want to setup timestamp for my search.

Args oneshotSearchArgs = new Args();
oneshotSearchArgs.put("earliest_time", "2019-02-19T12:00:00.000-07:00");
oneshotSearchArgs.put("latest_time", "2019-02-20T12:00:00.000-07:00");
String oneshotSearchQuery ="search index=app | head 2";

Instead giving date manually, i want to give

earliest_time --> 2 days
latest_time --> now

How can i do it?

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@Hunterzz

You can specify Splunk time modifier in oneshot arguments. Please check below link for Splunk time modifier example.

https://docs.splunk.com/Documentation/Splunk/7.2.5/Search/Specifytimemodifiersinyoursearch#Examples_...

Please check To run a basic oneshot search and display results
in http://dev.splunk.com/view/java-sdk/SP-CAAAEHQ .

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...