Link Search Menu Expand Document Documentation Menu

获取任务

1.0 版引入

获取任务 API 返回单个任务的详细信息。

端点

GET /_tasks/{task_id}

路径参数

下表列出了可用的路径参数。

参数 必需 数据类型 描述
task_id 必需 字符串 任务 ID。

查询参数

下表列出了可用的查询参数。所有查询参数都是可选的。

参数 数据类型 描述 默认值
timeout 字符串 等待响应的时间量。 30秒
wait_for_completion 布尔型 等待匹配的任务完成。当为 true 时,请求将阻塞直到任务完成。 false

请求示例

以下请求返回有关活动搜索任务的详细信息

curl -XGET "localhost:9200/_tasks?actions=*search&detailed

示例响应

以下响应返回有关 transport 任务的详细信息

{
  "nodes": {
    "JzrCxdtFTCO_RaINw8ckNA": {
      "name": "node-1",
      "transport_address": "127.0.0.1:9300",
      "host": "127.0.0.1",
      "ip": "127.0.0.1:9300",
      "roles": [
        "data",
        "ingest",
        "cluster_manager",
        "remote_cluster_client"
      ],
      "tasks": {
        "JzrCxdtFTCO_RaINw8ckNA:54321": {
          "node": "JzrCxdtFTCO_RaINw8ckNA",
          "id": 54321,
          "type": "transport",
          "action": "indices:data/read/search",
          "status": {
            "total": 1000,
            "created": 0,
            "updated": 0,
            "deleted": 0,
            "batches": 1,
            "version_conflicts": 0,
            "noops": 0,
            "retries": {
              "bulk": 0,
              "search": 0
            },
            "throttled_millis": 0,
            "requests_per_second": -1.0,
            "throttled_until_millis": 0
          },
          "description": "indices[test_index], types[_doc], search_type[QUERY_THEN_FETCH], source[{\"query\":{\"match_all\":{}}}]",
          "start_time_in_millis": 1625145678901,
          "running_time_in_nanos": 2345678,
          "cancellable": true
        }
      }
    }
  }
}

resource_stats 对象

resource_stats 对象仅针对支持资源跟踪的任务进行更新。这些统计数据是根据计划的线程执行计算的,包括已完成任务的线程和当前正在处理任务的线程。因为同一个线程可能多次被调度来处理同一个任务,所以给定线程的每个调度实例被视为单个线程执行。

下表列出了 resource_stats 对象中的所有响应字段。

响应字段 描述
平均值 所有已安排线程执行的平均资源使用量。
总计 所有已安排线程执行的总资源使用量。
最小值 所有已安排线程执行的最小资源使用量。
最大值 所有已安排线程执行的最大资源使用量。
thread_info 线程计数相关统计数据。
thread_info.active_threads 当前正在处理任务的线程数。
thread_info.thread_executions 已安排处理任务的线程数。
剩余 350 字符

有问题?

想贡献吗?