Get all tasks
- GET /_tasks
Get information about the tasks currently running on one or more nodes in the cluster.
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.
Identifying running tasks
The X-Opaque-Id header, when provided on the HTTP request header, is going to be returned as a header in the response as well as in the headers field for in the task information.
This enables you to track certain calls or associate certain tasks with the client that started them.
For example:
curl -i -H "X-Opaque-Id: 123456" "http://localhost:9200/_tasks?group_by=parents"
The API returns the following result:
HTTP/1.1 200 OK
X-Opaque-Id: 123456
content-type: application/json; charset=UTF-8
content-length: 831
{
"tasks" : {
"u5lcZHqcQhu-rUoFaqDphA:45" : {
"node" : "u5lcZHqcQhu-rUoFaqDphA",
"id" : 45,
"type" : "transport",
"action" : "cluster:monitor/tasks/lists",
"start_time_in_millis" : 1513823752749,
"running_time_in_nanos" : 293139,
"cancellable" : false,
"headers" : {
"X-Opaque-Id" : "123456"
},
"children" : [
{
"node" : "u5lcZHqcQhu-rUoFaqDphA",
"id" : 46,
"type" : "direct",
"action" : "cluster:monitor/tasks/lists[n]",
"start_time_in_millis" : 1513823752750,
"running_time_in_nanos" : 92133,
"cancellable" : false,
"parent_task_id" : "u5lcZHqcQhu-rUoFaqDphA:45",
"headers" : {
"X-Opaque-Id" : "123456"
}
}
]
}
}
}
In this example, X-Opaque-Id: 123456 is the ID as a part of the response header.
The X-Opaque-Id in the task headers is the ID for the task that was initiated by the REST request.
The X-Opaque-Id in the children headers is the child task of the task that was initiated by the REST request.
- Cluster privileges:
monitor
Query Parameters
-
actionsstring | string A comma-separated list or wildcard expression of actions used to limit the request. For example, you can use
cluser:*to retrieve all cluster-related tasks.-
detailedboolean · default: false If
true, the response includes detailed information about the running tasks. This information is useful to distinguish tasks from each other but is more costly to run.-
group_byGroupBy · default: nodes A key that is used to group tasks in the response. The task lists can be grouped either by nodes or by parent tasks.
Supported values include:
nodes: Group tasks by node ID.parents: Group tasks by parent task ID.none: Do not group tasks.
-
Values:
nodesparentsnone -
nodesNodeIds A comma-separated list of node IDs or names that is used to limit the returned information.
-
parent_task_idstring Id A parent task identifier that is used to limit returned information. To return all tasks, omit this parameter or use a value of
-1. If the parent task is not found, the API does not return a 404 response code.-
timeoutstring Duration · default: 30s The period to wait for each node to respond. If a node does not respond before its timeout expires, the response does not include its information. However, timed out nodes are included in the
node_failuresproperty.-
wait_for_completionboolean · default: false If
true, the request blocks until the operation is complete.
Response
-
node_failuresErrorCause -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
task_failuresTaskFailure -
task_idnumberrequired -
node_idstringrequired -
statusstringrequired -
reasonErrorCauserequired -
typestringrequired -
The type of error
-
reasonstringnullable -
A human-readable explanation of the error, in English.
-
stack_tracestring -
The server stack trace. Present only if the
error_trace=trueparameter was sent with the request. -
caused_byErrorCause -
root_causeErrorCause -
suppressedErrorCause -
nodesmap string to NodeTasks -
Task information grouped by node, if
group_bywas set tonode(the default). -
<string>NodeTasks -
namestring -
transport_addressstring -
hoststring -
ipstring -
rolesstring -
attributesmap string to string -
tasksmap string to TaskInforequired -
<string>TaskInfo -
actionstringrequired -
cancelledboolean -
cancellablebooleanrequired -
descriptionstring -
Human readable text that identifies the particular request that the task is performing. For example, it might identify the search request being performed by a search task. Other kinds of tasks have different descriptions, like
_reindexwhich has the source and the destination, or_bulkwhich just has the number of requests and the destination indices. Many requests will have only an empty description because more detailed information about the request is not easily available or particularly helpful in identifying the request. -
headersmap string to stringrequired -
idnumberrequired -
nodestringrequired -
running_timestring Duration -
running_time_in_nanosDurationValueUnitNanosrequired -
start_time_in_millisEpochTimeUnitMillisrequired -
statusobject -
The internal status of the task, which varies from task to task. The format also varies. While the goal is to keep the status for a particular task consistent from version to version, this is not always possible because sometimes the implementation changes. Fields might be removed from the status for a particular request so any parsing you do of the status might break in minor releases.
-
typestringrequired -
parent_task_idnumber | string TaskId -
tasksTaskInfos -
Either a flat list of tasks if
group_bywas set tonone, or grouped by parents ifgroup_bywas set toparents.