Elasticsearch 具有选定标题的易于阅读的表格化集群健康状况

示例

该示例使用基本的HTTP语法。<#>复制示例时,应删除示例中的所有内容。

像_catElasticsearch中的大多数API一样,API有选择地响应默认字段集。但是,如果需要,API中还存在其他字段:

GET /_cat/health?help <1>

  1. ?help 使API返回字段(和简称)以及简短说明。

_cat/health 从Elasticsearch 1.x开始存在,但是这里是Elasticsearch 5.x输出的示例:

此示例创建日期之前可用的字段:

epoch                 | t,time                                   | seconds since 1970-01-01 00:00:00  
timestamp             | ts,hms,hhmmss                            | time in HH:MM:SS                   
cluster               | cl                                       | cluster name                       
status                | st                                       | health status                      
node.total            | nt,nodeTotal                             | total number of nodes              
node.data             | nd,nodeData                              | number of nodes that can store data
shards                | t,sh,shards.total,shardsTotal            | total number of shards             
pri                   | p,shards.primary,shardsPrimary           | number of primary shards           
relo                  | r,shards.relocating,shardsRelocating     | number of relocating nodes         
init                  | i,shards.initializing,shardsInitializing | number of initializing nodes       
unassign              | u,shards.unassigned,shardsUnassigned     | number of unassigned shards        
pending_tasks         | pt,pendingTasks                          | number of pending tasks            
max_task_wait_time    | mtwt,maxTaskWaitTime                     | wait time of longest task pending  
active_shards_percent | asp,activeShardsPercent                  | active number of shards in percent

然后,您可以使用它仅打印那些字段:

GET /_cat/health?h=timestamp,cl,status&v <1>

  1. h=... 定义要返回的字段列表。

  2. v (详细)定义您希望它打印标题。

Elasticsearch 5.x实例的输出:

timestamp cl            status
15:38:00  elasticsearch yellow