List tasks
Introduced 1.0
The List Tasks API returns a list of tasks running in the cluster.
Endpoints
GET /_tasks
Query parameters
The following table lists the available query parameters. All query parameters are optional.
Parameter | Data type | Description | Default |
---|---|---|---|
actions | List or String | A comma-separated list of actions that should be returned. Keep empty to return all. | N/A |
detailed | Boolean | When true , the response includes detailed information about shard recoveries. | false |
group_by | String | Groups tasks by parent/child relationships or nodes. Valid values are: nodes , none , parents | nodes |
nodes | List | A comma-separated list of node IDs or names used to limit the returned information. Use _local to return information from the node you’re connecting to, specify the node name to get information from a specific node, or keep the parameter empty to get information from all nodes. | N/A |
parent_task_id | String | Returns tasks with a specified parent task ID (node_id:task_number ). Keep empty or set to -1 to return all. | N/A |
timeout | String | The amount of time to wait for a response. | N/A |
wait_for_completion | Boolean | Waits for the matching task to complete. When true , the request is blocked until the task has completed. | false |
Example request
The following request returns tasks currently running on a node named opensearch-node1
:
GET /_tasks?nodes=opensearch-node1
Example response
The following response provides information about running tasks:
{
"nodes": {
"Mgqdm0r9SEGClWxp_RbnaQ": {
"name": "opensearch-node1",
"transport_address": "sample_address",
"host": "sample_host",
"ip": "sample_ip",
"roles": [
"data",
"ingest",
"master",
"remote_cluster_client"
],
"tasks": {
"Mgqdm0r9SEGClWxp_RbnaQ:24578": {
"node": "Mgqdm0r9SEGClWxp_RbnaQ",
"id": 24578,
"type": "transport",
"action": "cluster:monitor/tasks/lists",
"start_time_in_millis": 1611612517044,
"running_time_in_nanos": 638700,
"cancellable": false,
"headers": {}
},
"Mgqdm0r9SEGClWxp_RbnaQ:24579": {
"node": "Mgqdm0r9SEGClWxp_RbnaQ",
"id": 24579,
"type": "direct",
"action": "cluster:monitor/tasks/lists[n]",
"start_time_in_millis": 1611612517044,
"running_time_in_nanos": 222200,
"cancellable": false,
"parent_task_id": "Mgqdm0r9SEGClWxp_RbnaQ:24578",
"headers": {}
}
}
}
}
}
The resource_stats
object
The resource_stats
object is only updated for tasks that support resource tracking. These statistics are computed based on scheduled thread executions, including both threads that have finished working on the task and threads currently working on the task. Because the same thread may be scheduled to work on the same task multiple times, each instance of a given thread being scheduled to work on a given task is considered to be a single thread execution.
The following table lists all response fields in the resource_stats
object.
Response field | Description |
---|---|
average | The average resource usage across all scheduled thread executions. |
total | The total resource usage across all scheduled thread executions. |
min | The minimum resource usage across all scheduled thread executions. |
max | The maximum resource usage across all scheduled thread executions. |
thread_info | Thread-count-related statistics. |
thread_info.active_threads | The number of threads currently working on the task. |
thread_info.thread_executions | The number of threads that have been scheduled to work on the task. |