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

获取集群中各个节点的使用情况统计信息,特别是 REST API 的调用统计和聚合器使用统计。

API #

GET /_cluster/nodes/usage
GET /_nodes/usage
GET /_nodes/{nodeId}/usage
GET /_nodes/usage/{metric}
GET /_nodes/{nodeId}/usage/{metric}

API 的作用 #

该 API 用于获取集群中各个节点的使用情况统计信息,可以返回:

指标描述
rest_actionsREST API 调用统计(每个 REST 端点被调用的次数)
aggregations聚合器使用统计

这对于监控和调试非常有用,可以帮助开发者了解各个节点的 API 使用情况和性能指标。

API 的参数 #

路由参数 #

参数类型是否必填默认值描述
{nodeId}字符串所有节点指定要获取使用情况的节点。可以是节点 ID、节点名称,或逗号分隔的列表。特殊值:_local 表示当前连接的节点
{metric}字符串_all指定要获取的指标类型。可选值:_allrest_actions

Query String 参数 #

参数类型是否必填默认值描述
timeout时间值默认超时显式设置操作的超时时间

可用的指标(metrics) #

指标值描述
_all所有指标(包括 rest_actions 和 aggregations)
rest_actionsREST API 调用统计

参数说明 #

  1. metric 参数默认值_all
  2. 当 metric 为 _all 时,会同时启用 rest_actions 和 aggregations
  3. 不能同时使用 _all 和具体的指标

示例 #

获取所有节点的所有使用情况统计 #

GET /_cluster/nodes/usage

GET /_nodes/usage

获取指定节点的使用情况 #

GET /_nodes/node1/usage

获取所有节点的 REST API 调用统计 #

GET /_nodes/usage/rest_actions

获取本地节点的使用情况 #

GET /_nodes/_local/usage

响应示例:

{
  "cluster_name": "easysearch-cluster",
  "nodes": {
    "node1_id": {
      "name": "node-1",
      "host": "192.168.1.1",
      "ip": "192.168.1.1",
      "rest_actions": {
        "org.easysearch.rest.action.RestMainAction": 100,
        "org.easysearch.rest.action.RestSearchAction": 500,
        "org.easysearch.rest.action.RestIndexAction": 200
      },
      "aggregations": {
        "terms": 300,
        "date_histogram": 150,
        "avg": 200
      },
      "since": "2026-02-04T00:00:00Z"
    }
  }
}