Elasticsearch cat Apis

1、_cat列入所有有效命令

GET /_cat

返回:有个猫...所以不难想象为啥是cat api
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates

2、通用参数

2.1 verbose参数,显示命令详细信息

GET /_cat/master?v

result:
id                     host          ip            node
Sa5md_zERDebxloO004ffQ 192.168.31.10 192.168.31.10 vmstation.es.1

没有加?v的情况,result:
Sa5md_zERDebxloO004ffQ 192.168.31.10 192.168.31.10 vmstation.es.1

2.2 help参数,显示有效列的详细说明

GET /_cat/master?help

result:
id   |   | node id    
host | h | host name  
ip   |   | ip address 
node | n | node name  

2.3 header参数,选择显示的列

GET /_cat/nodes?h=ip,port,heapPercent,name  

result:
192.168.31.10 9300 43 vmstation.es.1

2.4、响应体返回格式,支持json,yaml,text(default),smile,cbor

json格式
GET /_cat/indices?format=json&pretty result: [ { "health" : "green", "status" : "open", "index" : ".monitoring-kibana-6-2018.12.24", "uuid" : "vkJltBs1T8qEfdUDdyDYzA", "pri" : "1", "rep" : "0", "docs.count" : "1345", "docs.deleted" : "0", "store.size" : "453.3kb", "pri.store.size" : "453.3kb" }, { "health" : "green", "status" : "open", "index" : "user2", "uuid" : "xo9Zb2OkRWeqV5bRKNDKGg", "pri" : "1", "rep" : "0", "docs.count" : "12", "docs.deleted" : "0", "store.size" : "7.9kb", "pri.store.size" : "7.9kb" }, ..... ]

2.5、多个参数混合使用,一个问号,参数用&连接

GET /_cat/nodes?v&h=ip,port,heapPercent,name

result:
ip            port heapPercent name
192.168.31.10 9300          59 vmstation.es.1

2.6、排序sort,缺省是asc排序

GET /_cat/indices?v&h=health,index,store.size&s=store.size:desc

result:
health index                           store.size
green  .monitoring-es-6-2018.12.24           10mb
green  .monitoring-es-6-2018.12.20            5mb
green  .monitoring-es-6-2018.12.25          4.4mb
green  .monitoring-kibana-6-2018.12.24    453.3kb
green  .monitoring-kibana-6-2018.12.20      318kb
green  .monitoring-kibana-6-2018.12.25    195.2kb
yellow bus                                   86kb
yellow blog                                34.3kb
green  shirts                                25kb
yellow home                                16.8kb
green  user                                13.7kb
green  .kibana_1                             12kb
green  bus2                                11.6kb
green  user2                                7.9kb
green  user3                                 261b
多个字段排序:
GET /_cat/indices?v&h=health,index,store.size,pri.store.size&s=store.size:desc,pri.store.size:desc

result:
health index                           store.size pri.store.size
green  .monitoring-es-6-2018.12.24           10mb           10mb
green  .monitoring-es-6-2018.12.20            5mb            5mb
green  .monitoring-es-6-2018.12.25          4.6mb          4.6mb
green  .monitoring-kibana-6-2018.12.24    453.3kb        453.3kb
green  .monitoring-kibana-6-2018.12.20      318kb          318kb
green  .monitoring-kibana-6-2018.12.25    202.4kb        202.4kb
yellow bus                                   86kb           86kb
yellow blog                                34.3kb         34.3kb
green  shirts                                25kb           25kb
yellow home                                16.8kb         16.8kb
green  user                                13.7kb         13.7kb
green  .kibana_1                             12kb           12kb
green  bus2                                11.6kb         11.6kb
green  user2                                7.9kb          7.9kb
green  user3                                 261b           261b

3、aliases显示别名、过滤器、路由信息

GET /_cat/aliases?v

result:
alias   index     filter routing.index routing.search
.kibana .kibana_1 -      -             -

4、allocation显示每个数据节点分配多少碎片以及它们使用多少磁盘空间的快照

GET /_cat/allocation?v&format=json

result:
[
  {
    "shards" : "20",
    "disk.indices" : "21.4mb",
    "disk.used" : "4gb",
    "disk.avail" : "12.9gb",
    "disk.total" : "16.9gb",
    "disk.percent" : "23",
    "host" : "192.168.31.10",
    "ip" : "192.168.31.10",
    "node" : "vmstation.es.1"
  },
  {
    "shards" : "7",
    "disk.indices" : null,
    "disk.used" : null,
    "disk.avail" : null,
    "disk.total" : null,
    "disk.percent" : null,
    "host" : null,
    "ip" : null,
    "node" : "UNASSIGNED"
  }
]
#7个碎片是曾经属于一个集群,现在只有单节点,但是索引建立的时候使用它作为副本,所以信息都是未知的。

5、count显示所有索引或者某个索引的文档数量

GET /_cat/count?v

result:
epoch      timestamp count
1545709338 03:42:18  47638

或者单个索引

GET /_cat/count/bus?v

result:
epoch      timestamp count
1545709383 03:43:03  27

6、fielddata

GET /_cat/fielddata?v

result:
id                     host          ip            node           field size
Sa5md_zERDebxloO004ffQ 192.168.31.10 192.168.31.10 vmstation.es.1 type  552b

7、indices显示每个索引的横截面。此信息跨越节点。

GET /_cat/indices?v

result:
health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .monitoring-kibana-6-2018.12.24 vkJltBs1T8qEfdUDdyDYzA   1   0       1345            0    453.3kb        453.3kb
green  open   user2                           xo9Zb2OkRWeqV5bRKNDKGg   1   0         12            0      7.9kb          7.9kb
yellow open   bus                             G4DrNdPhRWK_rBuEaluwsA   3   1         27            3       86kb           86kb
green  open   .monitoring-es-6-2018.12.25     Gl01crYyQImkxCTGvB3Xkg   1   0      16845          189     15.6mb         15.6mb
green  open   shirts                          NLF5tjIuSz-JbUQcc_VbiQ   1   0          7            0       25kb           25kb
green  open   .monitoring-kibana-6-2018.12.20 GRwFygbPRw62Qeoyg-68Mg   1   0        719            0      318kb          318kb
green  open   .monitoring-kibana-6-2018.12.25 TmCzVC4wQrmmElX8Bbmjdg   1   0        866            0    710.2kb        710.2kb
green  open   .monitoring-es-6-2018.12.20     IH3moZNyQfCHp8ZUjelmWA   1   0       9548          215        5mb            5mb
yellow open   home                            CSyKu2FJTZGtSIg0jOltcw   2   1          7            0     16.8kb         16.8kb
green  open   .monitoring-es-6-2018.12.24     jCgptARpQ8S-B3Gn8adYSQ   1   0      23936           25       10mb           10mb
yellow open   blog                            G7leckf1RQGHNCZKROpBCg   2   1         33            6     34.3kb         34.3kb
green  open   .kibana_1                       olE1g78PTl-FxApa5LXhtg   1   0          3            0       12kb           12kb
green  open   user3                           -ArWuP3ZRsGsoiLwMxRyKQ   1   0          0            0       261b           261b
green  open   bus2                            j2ckAmxCRjuH6xVCU1aATA   1   0         27            0     11.6kb         11.6kb
green  open   user                            WdRH_r9DSDOtySMxlRYe_g   2   0         12            0     13.7kb         13.7kb

单个索引(支持通配符):

GET /_cat/indices/bus*?v&h=index,status,pri,rep,docs.count

result:
index status pri rep docs.count
bus2  open     1   0         27
bus   open     3   1         27

或者

GET /_cat/indices?v&index=bus*

8、master显示master节点

GET /_cat/master?v

result:
id                     host          ip            node
Sa5md_zERDebxloO004ffQ 192.168.31.10 192.168.31.10 vmstation.es.1

9、nodeattrs显示节点属性

GET /_cat/nodeattrs?v&h=node,id,pid,host,port,attr,value

result:
node           id   pid  host          port attr              value
vmstation.es.1 Sa5m 1763 192.168.31.10 9300 ml.machine_memory 1911832576
vmstation.es.1 Sa5m 1763 192.168.31.10 9300 xpack.installed   true
vmstation.es.1 Sa5m 1763 192.168.31.10 9300 ml.max_open_jobs  20
vmstation.es.1 Sa5m 1763 192.168.31.10 9300 ml.enabled        true

10、nodes显示集群拓扑

GET /_cat/nodes?v&format=json

result:
[
  {
    "ip" : "192.168.31.10",
    "heap.percent" : "40",
    "ram.percent" : "95",
    "cpu" : "7",
    "load_1m" : "0.25",
    "load_5m" : "0.19",
    "load_15m" : "0.13",
    "node.role" : "mdi",
    "master" : "*",
    "name" : "vmstation.es.1"
  }
]
    

列内容包括:

id                           | id,nodeId                      | unique node id                                                                                                   
pid                          | p                              | process id                                                                                                       
ip                           | i                              | ip address                                                                                                       
port                         | po                             | bound transport port                                                                                             
http_address                 | http                           | bound http address                                                                                               
version                      | v                              | es version                                                                                                       
flavor                       | f                              | es distribution flavor                                                                                           
type                         | t                              | es distribution type                                                                                             
build                        | b                              | es build hash                                                                                                    
jdk                          | j                              | jdk version                                                                                                      
disk.total                   | dt,diskTotal                   | total disk space                                                                                                 
disk.used                    | du,diskUsed                    | used disk space                                                                                                  
disk.avail                   | d,da,disk,diskAvail            | available disk space                                                                                             
disk.used_percent            | dup,diskUsedPercent            | used disk space percentage                                                                                       
heap.current                 | hc,heapCurrent                 | used heap                                                                                                        
heap.percent                 | hp,heapPercent                 | used heap ratio                                                                                                  
heap.max                     | hm,heapMax                     | max configured heap                                                                                              
ram.current                  | rc,ramCurrent                  | used machine memory                                                                                              
ram.percent                  | rp,ramPercent                  | used machine memory ratio                                                                                        
ram.max                      | rm,ramMax                      | total machine memory                                                                                             
file_desc.current            | fdc,fileDescriptorCurrent      | used file descriptors                                                                                            
file_desc.percent            | fdp,fileDescriptorPercent      | used file descriptor ratio                                                                                       
file_desc.max                | fdm,fileDescriptorMax          | max file descriptors                                                                                             
cpu                          | cpu                            | recent cpu usage                                                                                                 
load_1m                      | l                              | 1m load avg                                                                                                      
load_5m                      | l                              | 5m load avg                                                                                                      
load_15m                     | l                              | 15m load avg                                                                                                     
uptime                       | u                              | node uptime                                                                                                      
node.role                    | r,role,nodeRole                | m:master eligible node, d:data node, i:ingest node, -:coordinating node only                                     
master                       | m                              | *:current master                                                                                                 
name                         | n                              | node name                                                                                                        
completion.size              | cs,completionSize              | size of completion                                                                                               
fielddata.memory_size        | fm,fielddataMemory             | used fielddata cache                                                                                             
fielddata.evictions          | fe,fielddataEvictions          | fielddata evictions                                                                                              
query_cache.memory_size      | qcm,queryCacheMemory           | used query cache                                                                                                 
query_cache.evictions        | qce,queryCacheEvictions        | query cache evictions                                                                                            
request_cache.memory_size    | rcm,requestCacheMemory         | used request cache                                                                                               
request_cache.evictions      | rce,requestCacheEvictions      | request cache evictions                                                                                          
request_cache.hit_count      | rchc,requestCacheHitCount      | request cache hit counts                                                                                         
request_cache.miss_count     | rcmc,requestCacheMissCount     | request cache miss counts                                                                                        
flush.total                  | ft,flushTotal                  | number of flushes                                                                                                
flush.total_time             | ftt,flushTotalTime             | time spent in flush                                                                                              
get.current                  | gc,getCurrent                  | number of current get ops                                                                                        
get.time                     | gti,getTime                    | time spent in get                                                                                                
get.total                    | gto,getTotal                   | number of get ops                                                                                                
get.exists_time              | geti,getExistsTime             | time spent in successful gets                                                                                    
get.exists_total             | geto,getExistsTotal            | number of successful gets                                                                                        
get.missing_time             | gmti,getMissingTime            | time spent in failed gets                                                                                        
get.missing_total            | gmto,getMissingTotal           | number of failed gets                                                                                            
indexing.delete_current      | idc,indexingDeleteCurrent      | number of current deletions                                                                                      
indexing.delete_time         | idti,indexingDeleteTime        | time spent in deletions                                                                                          
indexing.delete_total        | idto,indexingDeleteTotal       | number of delete ops                                                                                             
indexing.index_current       | iic,indexingIndexCurrent       | number of current indexing ops                                                                                   
indexing.index_time          | iiti,indexingIndexTime         | time spent in indexing                                                                                           
indexing.index_total         | iito,indexingIndexTotal        | number of indexing ops                                                                                           
indexing.index_failed        | iif,indexingIndexFailed        | number of failed indexing ops                                                                                    
merges.current               | mc,mergesCurrent               | number of current merges                                                                                         
merges.current_docs          | mcd,mergesCurrentDocs          | number of current merging docs                                                                                   
merges.current_size          | mcs,mergesCurrentSize          | size of current merges                                                                                           
merges.total                 | mt,mergesTotal                 | number of completed merge ops                                                                                    
merges.total_docs            | mtd,mergesTotalDocs            | docs merged                                                                                                      
merges.total_size            | mts,mergesTotalSize            | size merged                                                                                                      
merges.total_time            | mtt,mergesTotalTime            | time spent in merges                                                                                             
refresh.total                | rto,refreshTotal               | total refreshes                                                                                                  
refresh.time                 | rti,refreshTime                | time spent in refreshes                                                                                          
refresh.listeners            | rli,refreshListeners           | number of pending refresh listeners                                                                              
script.compilations          | scrcc,scriptCompilations       | script compilations                                                                                              
script.cache_evictions       | scrce,scriptCacheEvictions     | script cache evictions                                                                                           
search.fetch_current         | sfc,searchFetchCurrent         | current fetch phase ops                                                                                          
search.fetch_time            | sfti,searchFetchTime           | time spent in fetch phase                                                                                        
search.fetch_total           | sfto,searchFetchTotal          | total fetch ops                                                                                                  
search.open_contexts         | so,searchOpenContexts          | open search contexts                                                                                             
search.query_current         | sqc,searchQueryCurrent         | current query phase ops                                                                                          
search.query_time            | sqti,searchQueryTime           | time spent in query phase                                                                                        
search.query_total           | sqto,searchQueryTotal          | total query phase ops                                                                                            
search.scroll_current        | scc,searchScrollCurrent        | open scroll contexts                                                                                             
search.scroll_time           | scti,searchScrollTime          | time scroll contexts held open                                                                                   
search.scroll_total          | scto,searchScrollTotal         | completed scroll contexts                                                                                        
segments.count               | sc,segmentsCount               | number of segments                                                                                               
segments.memory              | sm,segmentsMemory              | memory used by segments                                                                                          
segments.index_writer_memory | siwm,segmentsIndexWriterMemory | memory used by index writer                                                                                      
segments.version_map_memory  | svmm,segmentsVersionMapMemory  | memory used by version map                                                                                       
segments.fixed_bitset_memory | sfbm,fixedBitsetMemory         | memory used by fixed bit sets for nested object field types and type filters for types referred in _parent fields
suggest.current              | suc,suggestCurrent             | number of current suggest ops                                                                                    
suggest.time                 | suti,suggestTime               | time spend in suggest                                                                                            
suggest.total                | suto,suggestTotal              | number of suggest ops                                                                                            

选择显示内容:

GET /_cat/nodes?v&format=json&h=id,i,p,http,v,j,dt,du,hc,hp,hx,rc,rp,rm

result:
[
  {
    "id" : "Sa5m",
    "i" : "192.168.31.10",
    "p" : "1763",
    "http" : "192.168.31.10:9200",
    "v" : "6.5.1",
    "j" : "1.8.0_172",
    "dt" : "16.9gb",
    "du" : "4.1gb",
    "hc" : "461mb",
    "hp" : "45",
    "rc" : "1.6gb",
    "rp" : "94",
    "rm" : "1.7gb"
  }
]

11、显示正在等待的任务

GET /_cat/pending_tasks?v

result:
insertOrder timeInQueue priority source
       1685       855ms HIGH     update-mapping [foo][t]
       1686       843ms HIGH     update-mapping [foo][t]
       1693       753ms HIGH     refresh-mapping [foo][[t]]
       1688       816ms HIGH     update-mapping [foo][t]
       1689       802ms HIGH     update-mapping [foo][t]
       1690       787ms HIGH     update-mapping [foo][t]
       1691       773ms HIGH     update-mapping [foo][t]

12、plugins显示每个运行插件节点的视图,该信息跨节点。

GET /_cat/plugins?v&s=component&h=name,component,version,description

result:
name           component   version description
vmstation.es.1 analysis-ik 6.5.1   IK Analyzer for Elasticsearch

13、recovery是正在进行的和先前完成的索引碎片恢复的视图。

只要索引碎片移动到集群中的不同节点,就会发生恢复事件。这可以在快照恢复、复制级别更改、节点失败或节点启动时发生。最后一种类型称为本地存储恢复,是当节点启动时从磁盘加载碎片的正常方式。

GET /_cat/recovery?v&format=json

result:
[
  {
    "index" : "user2",
    "shard" : "0",
    "time" : "333ms",
    "type" : "existing_store",
    "stage" : "done",
    "source_host" : "n/a",
    "source_node" : "n/a",
    "target_host" : "192.168.31.10",
    "target_node" : "vmstation.es.1",
    "repository" : "n/a",
    "snapshot" : "n/a",
    "files" : "0",
    "files_recovered" : "0",
    "files_percent" : "100.0%",
    "files_total" : "4",
    "bytes" : "0",
    "bytes_recovered" : "0",
    "bytes_percent" : "100.0%",
    "bytes_total" : "8105",
    "translog_ops" : "0",
    "translog_ops_recovered" : "0",
    "translog_ops_percent" : "100.0%"
  },
  {
    "index" : "bus",
    "shard" : "0",
    "time" : "388ms",
    "type" : "existing_store",
    "stage" : "done",
    "source_host" : "n/a",
    "source_node" : "n/a",
    "target_host" : "192.168.31.10",
    "target_node" : "vmstation.es.1",
    "repository" : "n/a",
    "snapshot" : "n/a",
    "files" : "0",
    "files_recovered" : "0",
    "files_percent" : "100.0%",
    "files_total" : "28",
    "bytes" : "0",
    "bytes_recovered" : "0",
    "bytes_percent" : "100.0%",
    "bytes_total" : "21695",
    "translog_ops" : "0",
    "translog_ops_recovered" : "0",
    "translog_ops_percent" : "100.0%"
  },
 ... ...
]

14、thread_pool显示线程池信息

GET /_cat/thread_pool?v

result:
node_name      name                active queue rejected
vmstation.es.1 analyze                  0     0        0
vmstation.es.1 ccr                      0     0        0
vmstation.es.1 fetch_shard_started      0     0        0
vmstation.es.1 fetch_shard_store        0     0        0
vmstation.es.1 flush                    0     0        0
vmstation.es.1 force_merge              0     0        0
vmstation.es.1 generic                  0     0        0
vmstation.es.1 get                      0     0        0
vmstation.es.1 index                    0     0        0
vmstation.es.1 listener                 0     0        0
vmstation.es.1 management               1     0        0
vmstation.es.1 ml_autodetect            0     0        0
vmstation.es.1 ml_datafeed              0     0        0
vmstation.es.1 ml_utility               0     0        0
vmstation.es.1 refresh                  0     0        0
vmstation.es.1 rollup_indexing          0     0        0
vmstation.es.1 search                   0     0        0
vmstation.es.1 search_throttled         0     0        0
vmstation.es.1 security-token-key       0     0        0
vmstation.es.1 snapshot                 0     0        0
vmstation.es.1 warmer                   0     0        0
vmstation.es.1 watcher                  0     0        0
vmstation.es.1 write                    0     0        0

15、shards显示碎片视图

GET /_cat/shards?v&format=json

result:
[
  {
    "index" : "bus2",
    "shard" : "0",
    "prirep" : "p",
    "state" : "STARTED",
    "docs" : "27",
    "store" : "11.6kb",
    "ip" : "192.168.31.10",
    "node" : "vmstation.es.1"
  },
  {
    "index" : ".kibana_1",
    "shard" : "0",
    "prirep" : "p",
    "state" : "STARTED",
    "docs" : "3",
    "store" : "12kb",
    "ip" : "192.168.31.10",
    "node" : "vmstation.es.1"
  },
... ...
]

按索引显示:

GET /_cat/shards/bus?v

result:
index shard prirep state      docs  store ip            node
bus   1     p      STARTED       7 27.8kb 192.168.31.10 vmstation.es.1
bus   1     r      UNASSIGNED                           
bus   2     p      STARTED       9   37kb 192.168.31.10 vmstation.es.1
bus   2     r      UNASSIGNED                           
bus   0     p      STARTED      11 21.1kb 192.168.31.10 vmstation.es.1
bus   0     r      UNASSIGNED                           

16、segments显示碎片中的分段信息

GET /_cat/segments?v&format=json

result:
index                           shard prirep ip            segment generation docs.count docs.deleted    size size.memory committed searchable version compound
user2                           0     p      192.168.31.10 _0               0         12            0   7.5kb        2726 true      true       7.5.0   true
bus                             0     p      192.168.31.10 _q              26          7            3   5.3kb        1982 true      true       7.5.0   false
bus                             0     p      192.168.31.10 _r              27          1            0   3.7kb        1827 true      true       7.5.0   true
bus                             0     p      192.168.31.10 _s              28          1            0   3.7kb        1827 true      true       7.5.0   true
bus                             0     p      192.168.31.10 _t              29          1            0   3.7kb        1827 true      true       7.5.0   true
bus                             0     p      192.168.31.10 _u              30          1            0   3.9kb        1965 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _7               7          1            0   3.9kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _8               8          1            0   3.9kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _9               9          1            0   3.9kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _a              10          1            0   3.9kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _b              11          1            0   3.9kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _c              12          1            0   3.8kb        1829 true      true       7.5.0   true
bus                             1     p      192.168.31.10 _f              15          1            0   3.5kb        1538 true      true       7.5.0   true
... ...

 

posted @ 2018-12-25 13:36  我是属车的  阅读(1047)  评论(0编辑  收藏  举报