<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there an option to stop a search job after a certain time through Splunk REST API? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206254#M60015</link>
    <description>&lt;P&gt;we can't get the jobid to send a cancel request. but the auto cancel seems to be working. Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2016 16:19:57 GMT</pubDate>
    <dc:creator>senthilkumar76</dc:creator>
    <dc:date>2016-09-27T16:19:57Z</dc:date>
    <item>
      <title>Is there an option to stop a search job after a certain time through Splunk REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206251#M60012</link>
      <description>&lt;P&gt;I have a Splunk search which takes long time to execute. I want to stop the Splunk job if it doesn't complete in a minute or 2. Does Splunk REST API have an option for that?&lt;/P&gt;

&lt;P&gt;I tried autocancel, timeout and job.cancel, nothing works. Any help greatly appreciated.&lt;/P&gt;

&lt;P&gt;code snippet&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    JobArgs jobargs = new JobArgs();
    jobargs.setAutoCancel(60);
    jobargs.setTimeout(0);
    jobargs.setExecutionMode(JobArgs.ExecutionMode.BLOCKING);

Service service =splunkconnection.connect();            
Job job = service.getJobs().create(query, jobargs);

JobResultsArgs resultsArgs = new JobResultsArgs();
resultsArgs.setCount(0);
resultsArgs.setOutputMode(JobResultsArgs.OutputMode.JSON);
InputStream resultsNormalSearch = job.getResults(resultsArgs);

reader= new ResultsReaderJson(resultsNormalSearch);
HashMap&amp;lt;String, String&amp;gt; event;
while ((event = reader.getNextEvent()) != null) {
  -- process response
}
resultsReader.close();
job.cancel();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 14:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206251#M60012</guid>
      <dc:creator>senthilkumar76</dc:creator>
      <dc:date>2016-09-22T14:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an option to stop a search job after a certain time through Splunk REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206252#M60013</link>
      <description>&lt;P&gt;Does any know how to implement this?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2016 13:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206252#M60013</guid>
      <dc:creator>senthilkumar76</dc:creator>
      <dc:date>2016-09-26T13:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an option to stop a search job after a certain time through Splunk REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206253#M60014</link>
      <description>&lt;P&gt;It looks like you can send a cancel request via the job control API:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fcontrol" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D.2Fcontrol&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It doesn't look exactly like what you are looking for, but there is also an auto_cancel and auto_finalize option to the jobs method when you submit a job.  &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#POST_search.2Fjobs_method_detail" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/RESTREF/RESTsearch#POST_search.2Fjobs_method_detail&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:13:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206253#M60014</guid>
      <dc:creator>Jeremiah</dc:creator>
      <dc:date>2020-09-29T11:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an option to stop a search job after a certain time through Splunk REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206254#M60015</link>
      <description>&lt;P&gt;we can't get the jobid to send a cancel request. but the auto cancel seems to be working. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 16:19:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-option-to-stop-a-search-job-after-a-certain-time/m-p/206254#M60015</guid>
      <dc:creator>senthilkumar76</dc:creator>
      <dc:date>2016-09-27T16:19:57Z</dc:date>
    </item>
  </channel>
</rss>

