Cancel a task Technical preview
WARNING: The task management API is new and should still be considered a beta feature. The API may change in ways that are not backwards compatible.
A task may continue to run for some time after it has been cancelled because it may not be able to safely stop its current activity straight away. It is also possible that Elasticsearch must complete its work on other tasks before it can process the cancellation. The get task information API will continue to list these cancelled tasks until they complete. The cancelled flag in the response indicates that the cancellation command has been processed and the task will stop as soon as possible.
To troubleshoot why a cancelled task does not complete promptly, use the get task information API with the ?detailed
parameter to identify the other tasks the system is running.
You can also use the node hot threads API to obtain detailed information about the work the system is doing instead of completing the cancelled task.
Query parameters
-
actions string | array[string]
A comma-separated list or wildcard expression of actions that is used to limit the request.
-
nodes array[string]
A comma-separated list of node IDs or names that is used to limit the request.
-
parent_task_id string
A parent task ID that is used to limit the tasks.
-
wait_for_completion boolean
If true, the request blocks until all found tasks are complete.
curl \
-X POST http://api.example.com/_tasks/_cancel
{
"node_failures": [
{
"type": "string",
"reason": "string",
"stack_trace": "string",
"caused_by": {},
"root_cause": [
{}
],
"suppressed": [
{}
]
}
],
"task_failures": [
{
"task_id": 42.0,
"node_id": "string",
"status": "string",
"reason": {
"type": "string",
"reason": "string",
"stack_trace": "string",
"caused_by": {},
"root_cause": [
{}
],
"suppressed": [
{}
]
}
}
],
"nodes": {
"additionalProperty1": {
"name": "string",
"transport_address": "string",
"host": "string",
"ip": "string",
"roles": [
"string"
],
"attributes": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"tasks": {
"additionalProperty1": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
},
"additionalProperty2": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
}
},
"additionalProperty2": {
"name": "string",
"transport_address": "string",
"host": "string",
"ip": "string",
"roles": [
"string"
],
"attributes": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"tasks": {
"additionalProperty1": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
},
"additionalProperty2": {
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
}
}
},
"": [
{
"action": "string",
"cancelled": true,
"cancellable": true,
"description": "string",
"headers": {
"additionalProperty1": "string",
"additionalProperty2": "string"
},
"id": 42.0,
"node": "string",
"running_time": "string",
"": "string",
"status": {},
"type": "string"
}
]
}