📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

获取集群中各个节点的热点线程信息,用于监控和分析 JVM 中线程的活动情况,帮助定位性能问题和瓶颈。

注意:该 API 已被标记为弃用(deprecated),推荐使用 /_nodes/hot_threads 替代。

API #

GET /_cluster/nodes/hot_threads
GET /_cluster/nodes/{nodeId}/hot_threads

API 的作用 #

该 API 用于获取集群中各个节点的热点线程信息,可以监控和分析 JVM 中线程的活动情况,帮助开发者定位性能问题和瓶颈。

热点线程类型:

  • cpu:基于 CPU 使用率排序,显示最消耗 CPU 的线程
  • wait:基于等待时间排序,显示等待时间最长的线程
  • block:基于阻塞时间排序,显示被阻塞时间最长的线程

API 的参数 #

路由参数 #

参数类型是否必填默认值描述
{nodeId}字符串所有节点指定要获取热点线程的节点。可以是逗号分隔的节点 ID 列表

Query String 参数 #

参数类型是否必填默认值描述
threads整数3要显示的最繁忙线程数量
ignore_idle_threads布尔值true是否忽略空闲线程
type字符串cpu热点线程类型。可选值:cpuwaitblock
interval时间值500ms采样间隔时间
snapshots整数10线程栈快照数量
timeout时间值默认超时请求超时时间

参数说明 #

type 参数详解 #

描述
cpu基于 CPU 使用率排序,显示最消耗 CPU 的线程
wait基于等待时间排序,显示等待时间最长的线程
block基于阻塞时间排序,显示被阻塞时间最长的线程

其他参数说明 #

  • interval:采样间隔时间,默认 500 毫秒,用于在检测热点线程时的两次采样间隔
  • ignore_idle_threads:设为 false 时会显示所有线程,包括空闲线程
  • snapshots:每个快照包含线程的调用栈信息

示例 #

获取所有节点的热点线程(CPU 类型) #

GET /_cluster/nodes/hot_threads

GET /_cluster/nodes/hot_threads?type=cpu

获取指定节点的热点线程 #

GET /_cluster/nodes/node1/hot_threads

获取等待类型的热点线程 #

GET /_cluster/nodes/hot_threads?type=wait

获取更多数量的热点线程 #

GET /_cluster/nodes/hot_threads?threads=10

获取包含空闲线程的信息 #

GET /_cluster/nodes/hot_threads?ignore_idle_threads=false

设置自定义采样间隔和快照数量 #

GET /_cluster/nodes/hot_threads?interval=1s&snapshots=20

响应格式 #

API 返回一个纯文本格式的报告,包含:

  • 每个节点的标识信息
  • 热点线程的详细信息,包括:
    • 线程名称和状态
    • 线程栈信息
    • 线程 CPU 时间/等待时间/阻塞时间(取决于 type 参数)

响应示例:

::: node1
Hot threads at 2026-02-04T08:00:00Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

100.0% (500ms out of 500ms) cpu usage by thread 'easysearch[node1][search]'
  10.0% (50ms) cpu usage by thread 'easysearch[node1][merge]'
  5.0% (25ms) cpu usage by thread 'easysearch[node1][generic]'

::: node2
Hot threads at 2026-02-04T08:00:00Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true: