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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...