Elasticsearch cat

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显示所有索引或者某个索引的文档数量

扫描二维码关注公众号,回复: 4643264 查看本文章
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*

猜你喜欢

转载自www.cnblogs.com/asker009/p/10173425.html
cat