1. 程式人生 > 其它 >Elasticsearch cat API的小結

Elasticsearch cat API的小結

個人學習筆記,謝絕轉載!!!

原文:https://www.cnblogs.com/wshenjin/p/15075759.html


所有的 cat 命令都接受查詢字串引數 help,以檢視它們提供的所有 header 和資訊。

_cat通用引數:

  • verbose :GET /_cat/XXX/?v , 開啟詳細輸出

  • help : GET /_cat/XXX/?help, 輸出可用的列

  • headers:GET /_cat/XXX/?h=column1,column2,指定輸出的列

  • sort :GET /_cat/XXX/?v&s=column1,column2:desc,column3,指定輸出的列進行排序,預設升序

  • format: GET /_cat/XXX?format=json,指定響應返回的資料格式, text(預設)、json、yaml、smile、cbor

列出_cat 支援的所有命令:

[root@ ~]# curl -XGET 'http://127.0.0.1:9200/_cat'                                                           
=^.^=
/_cat/allocation
/_cat/shards               #輸出分片的詳細資訊(是primary還是 replica,doc的數量,硬碟佔用大小以及在哪個節點等)
/_cat/shards/{index}
/_cat/master               #查詢master的節點ID,繫結IP地址,節點名稱
/_cat/nodes                #查詢前叢集的拓撲結構(包括當前節點所在的地方和整個叢集的相關資訊等
/_cat/tasks
/_cat/indices              #查詢叢集索引相關資訊
/_cat/indices/{index}
/_cat/segments             #輸出索引分片中關於segment的低層級的資訊(包括索引名稱,分片數量,doc數量等),提供的資訊類似於_segments端點
/_cat/segments/{index}
/_cat/count                #查詢當前整個叢集或者指定索引的document的數量(不包括刪除的但是還沒有清理掉的document)
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health               #查詢當前叢集的健康資訊(同/_cluster/health)
/_cat/pending_tasks        #查詢叢集正在執行的任務(比如:建立索引,更新mapping,分配或者fail shard)同 /_cluster/pending_tasks
/_cat/aliases              #查詢當前配置索引,過濾器,路由的別名
/_cat/aliases/{alias}
/_cat/thread_pool          #查詢每個節點叢集範圍的執行緒池統計資訊,預設情況下返回正在活動,佇列和被拒絕的統計資訊
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata            #查詢叢集中每個節點中的fileddata所使用的堆記憶體
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository} 
/_cat/templates

顯示header:

GET /_cat/shards?v

使用help引數來展示幫助資訊:

GET /_cat/shards?help

顯示所有欄位或需要的欄位:

GET /_cat/shards?v&h=*
GET /_cat/shards?v&h=index,shard,prirep,state,node,ip

對輸出進行排序:

GET /_cat/shards?v&h=index,shard,prirep,state,node,ip&s=store

針對某個index:

GET /_cat/shards/uint?v&h=index,shard,state,store,ip,node&s=store