获取集群中节点的详细信息,包括节点设置、操作系统信息、进程信息、JVM 信息、线程池、插件等。
API #
GET /_cluster/nodes/info
GET /_nodes
GET /_nodes/{nodeId}
GET /_nodes/{nodeId}/{metrics}
API 的作用 #
该 API 用于获取集群中节点的详细配置和状态信息,可以返回多种类型的节点信息,包括:
| 指标 | 描述 |
|---|---|
settings | 节点设置 |
os | 操作系统信息 |
process | 进程信息 |
jvm | JVM 信息 |
thread_pool | 线程池信息 |
transport | 传输信息 |
http | HTTP 信息 |
plugins | 插件和模块信息 |
ingest | 摄入管道信息 |
aggregations | 聚合信息 |
indices | 索引信息 |
search | 搜索管道信息 |
这对于集群监控、故障排除和性能分析非常有用。
API 的参数 #
路由参数 #
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
{nodeId} | 字符串 | 否 | _all | 指定要获取信息的节点。可以是节点 ID、节点名称或特殊值:_all(所有节点)、_local(本地节点)、_master(主节点) |
{metrics} | 字符串 | 否 | _all | 指定要获取的指标类型 |
Query String 参数 #
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
timeout | 时间值 | 否 | 默认超时 | 设置请求超时时间 |
可用的指标(metrics) #
| 指标值 | 描述 |
|---|---|
settings | 节点设置 |
os | 操作系统信息 |
process | 进程信息 |
jvm | JVM 信息 |
thread_pool | 线程池信息 |
transport | 传输信息 |
http | HTTP 信息 |
plugins | 插件和模块信息 |
ingest | 摄入管道信息 |
aggregations | 聚合信息 |
indices | 索引信息 |
search | 搜索管道信息 |
_all | 所有指标 |
示例 #
获取所有节点的所有信息 #
GET /_cluster/nodes/info
或
GET /_nodes
获取指定节点的信息 #
GET /_nodes/node1
获取所有节点的 OS 信息 #
GET /_nodes/os
获取指定节点的 JVM 信息 #
GET /_nodes/node1/jvm
获取本地节点的信息 #
GET /_nodes/_local
获取主节点的信息 #
GET /_nodes/_master
获取多个节点的信息 #
GET /_nodes/node1,node2,os,process
响应示例:
{
"cluster_name": "easysearch-cluster",
"nodes": {
"node1_id": {
"name": "node-1",
"transport_address": "192.168.1.1:9300",
"host": "192.168.1.1",
"ip": "192.168.1.1",
"version": "1.0.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "abc123",
"roles": [
"data",
"ingest",
"master"
],
"attributes": {
"attr_name": "attr_value"
},
"os": {
"name": "Linux",
"version": "5.15.0",
"available_processors": 8,
"allocated_processors": 8
},
"jvm": {
"version": "17.0.1",
"vm_name": "OpenJDK",
"vm_version": "17.0.1+12",
"vm_vendor": "Eclipse Adoptium",
"start_time_in_millis": 1641234567890,
"mem": {
"heap_init_in_bytes": 1073741824,
"heap_max_in_bytes": 1073741824
}
}
}
}
}





