具有選定標頭的人類可讀表格 Cluster Health

示例使用基本 HTTP 語法。複製時,應刪除示例中的任何 <#>

與 Elasticsearch 中的大多數 _cat 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