Splunk Search

How can I end a long running search job using the Splunk API?

bensonqiu
Engager

If I make a POST request to "services/search/jobs", it will return a job-id. Let's say the job is taking too long, and subsequent jobs are being queued because we cannot exceed the concurrency level. How can I use the API to kill the long-running search job?

0 Karma
1 Solution

yannK
Splunk Employee
Splunk Employee

1 -query the REST API to get the list of jobs running and their SID

see http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTTUT/RESTsearches

2 - find the ones you want to terminate

3 - call the job termination REST API endpoint for this job SID.
http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D...

example with curl to finalize job "mysearch_02151949"

 curl -k -u admin:pass https://localhost:8089/services/search/jobs/mysearch_02151949/control -d action=finalize

Remark : If you want to script , you can use the SDK to interact with the API
http://dev.splunk.com/sdks?r=searchtip

View solution in original post

yannK
Splunk Employee
Splunk Employee

1 -query the REST API to get the list of jobs running and their SID

see http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTTUT/RESTsearches

2 - find the ones you want to terminate

3 - call the job termination REST API endpoint for this job SID.
http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTREF/RESTsearch#search.2Fjobs.2F.7Bsearch_id.7D...

example with curl to finalize job "mysearch_02151949"

 curl -k -u admin:pass https://localhost:8089/services/search/jobs/mysearch_02151949/control -d action=finalize

Remark : If you want to script , you can use the SDK to interact with the API
http://dev.splunk.com/sdks?r=searchtip

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...