本博文讲述的ES获取系统数据的API是基于Elasticsearch 2.4.1版本的。

0. overview

a. 下面将要介绍的所有的指令,都支持一个查询参数v(verbose),用来显示详细的查询结果。

b. cat的所有指令,都支持一个help参数查询,帮助用户了解cat相关指令都支持那些功能。

c. cat的所有指令,都支持一个h参数的查询,指定指定的列信息进行输出。

例子: 查询输出master的ip以及node name

[elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/master?h=ip,n

  10.xxx.xx.xxx node-es2

1.  help查询参数

下面,就以一个查看当前ES集群master的信息的例子:

[elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/master?help
id | | node id
host | h | host name
ip | | ip address
node | n | node name

上面的输出含义,解释一下,指的是查看master信息时,能得到的帮助内容,cat获取master信息,将会得到master的节点id,即第一行,id:node id;第二行,表示host,可以简写成h,表示host name,第三行,表示master的ip,描述信息ip address, 第四行,node,简写成n,表示节点名字(node name).

不带help查询参数时,得到下面的信息:

[elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/master?v
id host ip node
9gKBOPrEQ0mtGpq8H0mzDg 10.xxx.xx.xxx 10.xxx.xx.xxx node-es2

还有一点,指的重点指出的是,当不输入任何cat的查询目标时,有help与没有help都是一个cat指令的帮助提示,如下:

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat              #此指令与curl http://localhost:9200/_cat?help得到的结果一样
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_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/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}

2. aliases指令

aliases指令可以查询出当前索引的filter以及routing所配置的别名信息。

 [root@localhost ~]# curl http://10.90.7.2:9201/_cat/aliases?v
alias index filter routing.index routing.search

上例中,表示我的系统中,没有配置任何的别名,这个在实际生产中,用的不是很多。

3. allocation指令

该指令提供一个快照,反映当前节点有多少个分片(shard)以及用了多少磁盘空间(disk)。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/allocation?v
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
.7mb .4gb .6gb 49gb 10.xxx.xx.xxx 10.xxx.xx.xxx node-es1
.1mb .4gb .6gb 49gb 10.xxx.xx.xxx 10.xxx.xx.xxx node-es2

4. count指令

该指令可以获取当前集群中有多少个document,类似mysql中有多少条记录,也可以获取指定index的document的数量。

 [root@localhost ~]# curl http://10.90.7.2:9201/_cat/indices?v                   #获取当前系统有多少个index
health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open megacorp 795b 795b
yellow open tkssearch .2kb .2kb
yellow open test .2kb .2kb
yellow open tk-search11 .2kb .2kb
yellow open cms .1kb .1kb
yellow open tksearch .3kb .3kb
yellow open rest_index .5kb .5kb
yellow open 795b 795b
yellow open 795b 795b
yellow open 795b 795b
yellow open indexdemo .2kb .2kb
yellow open indexdemo—— 795b 795b
yellow open tk-search-module .6kb .6kb
yellow open 795b 795b
yellow open 795b 795b
yellow open tksearch1 .5kb .5kb
yellow open tk-search .2mb .2mb
 [root@localhost ~]# curl http://10.90.7.2:9201/_cat/count?v         #获取当前集群中有多少个document
epoch timestamp count
::
 [root@localhost ~]# curl http://10.90.7.2:9201/_cat/count/tksearch?v    #获取tksearch这个index的document数量
epoch timestamp count
::

5. health指令

该指令反应当前集群的健康指数信息。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/health?v
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
:: tksearch green - 100.0%

6. indices指令,master指令,上面的例子中有所反应,不再举例。

7. nodeattrs指令

该指令可以反应出当前数据节点的属性信息。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/nodeattrs?v
node host ip attr value

注:这里查不到数据,没有弄明白,官网的说明中,有结果,是什么地方配置的问题?

8. node指令

该指令反应出当前集群的拓扑信息。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://10.130.203.111:9200/_cat/nodes?v
host ip heap.percent ram.percent load node.role master name
10.xxx.xx.xxx 10.xxx.xx.xxx 0.00 d m node-es1
10.yyy.yy.yyy 10.yyy.yy.yyy 0.00 d * node-es2

9. pending_tasks指令

该指令反应当前集群有多少任务处在pending状态,与指令/_cluster/pending_tasks的效果一样。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/pending_tasks?v
insertOrder timeInQueue priority source

上例说明没有处在pending状态的任务。

10. plugins指令

该指令提供一个视图,反应当前节点中处在运行状态的插件。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/plugins?v
name component version type url

11. recovery指令

该指令反应当前系统中,索引分片的恢复信息,包括正在进行的以及已经完成了的。恢复,指的是当节点添加或者减少时发生的数据移动造成的。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/recovery?v
index shard time type stage source_host target_host repository snapshot files files_percent bytes bytes_percent total_files total_bytes translog translog_percent total_translog
tk-search-module store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search-module replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%
tk-search-module replica done .yyy.yy.yyy .xxx.xx.xxx n/a n/a 100.0% 100.0% 100.0%
tk-search-module store done .yyy.yy.yyy .yyy.yy.yyy n/a n/a 0.0% 0.0% 100.0%
tk-search-module store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search-module replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%
tk-search-module replica done .yyy.yy.yyy .xxx.xx.xxx n/a n/a 100.0% 100.0% 100.0%
tk-search-module store done .yyy.yy.yyy .yyy.yy.yyy n/a n/a 0.0% 0.0% 100.0%
tk-search-module store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search-module replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%
tk-search store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%
tk-search replica done .yyy.yy.yyy .xxx.xx.xxx n/a n/a 100.0% 100.0% 100.0%
tk-search store done .yyy.yy.yyy .yyy.yy.yyy n/a n/a 0.0% 0.0% 100.0%
tk-search store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%
tk-search replica done .yyy.yy.yyy .xxx.xx.xxx n/a n/a 100.0% 100.0% 100.0%
tk-search store done .yyy.yy.yyy .yyy.yy.yyy n/a n/a 0.0% 0.0% 100.0%
tk-search store done .xxx.xx.xxx .xxx.xx.xxx n/a n/a 0.0% 0.0% 100.0%
tk-search replica done .xxx.xx.xxx .yyy.yy.yyy n/a n/a 100.0% 100.0% 100.0%

12. repositories指令

该指令反应当前集群中注册了多少个repository。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/repositories?v
id type

上例中表示没有注册repository到集群

13.  thread_pool指令

该指令反应当前集群中的thread pool在每一个节点上的统计信息。 “By default the active, queue and rejected statistics are returned for the bulk, index and search thread pools

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/thread_pool?v
host ip bulk.active bulk.queue bulk.rejected index.active index.queue index.rejected search.active search.queue search.rejected
.yyy.yy.yyy .yyy.yy.yyy
.xxx.xx.xxx .xxx.xx.xxx

14. shards指令

该指令,相对比较重要,反应每个节点有那些分片,告诉我们,那些是主分片,那些是从分片,每个分片的document数量,以及在该节点占用的磁盘空间。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/shards?v
index shard prirep state docs store ip node
tk-search-module p STARTED 159b .xxx.xx.xxx node-es2
tk-search-module r STARTED 159b .yyy.yy.yyy node-es1
tk-search-module r STARTED 159b .xxx.xx.xxx node-es2
tk-search-module p STARTED 159b .yyy.yy.yyy node-es1
tk-search-module r STARTED 159b .xxx.xx.xxx node-es2
tk-search-module p STARTED 159b .yyy.yy.yyy node-es1
tk-search-module p STARTED .4kb .xxx.xx.xxx node-es2
tk-search-module r STARTED .4kb .yyy.yy.yyy node-es1
tk-search-module p STARTED 159b .xxx.xx.xxx node-es2
tk-search-module r STARTED 159b .yyy.yy.yyy node-es1
tk-search p STARTED .5mb .xxx.xx.xxx node-es2
tk-search r STARTED .8mb .yyy.yy.yyy node-es1
tk-search r STARTED .5mb .xxx.xx.xxx node-es2
tk-search p STARTED .5mb .yyy.yy.yyy node-es1
tk-search r STARTED .6mb .xxx.xx.xxx node-es2
tk-search p STARTED .3mb .yyy.yy.yyy node-es1
tk-search p STARTED .5mb .xxx.xx.xxx node-es2
tk-search r STARTED 45mb .yyy.yy.yyy node-es1
tk-search p STARTED .7mb .xxx.xx.xxx node-es2
tk-search r STARTED .8mb .yyy.yy.yyy node-es1

15. segments指令

该指令反应的是在当前index中的某个shard的segment的信息,属于相对底层的信息。

 [elastic@t0-tkonline-cms-search01 ~]$ curl http://localhost:9200/_cat/segments?v
index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compound
tk-search-module p .xxx.xx.xxx _0 .2kb true true 5.5. true
tk-search-module r .yyy.yy.yyy _0 .2kb true true 5.5. true
tk-search p .xxx.xx.xxx _1bd .9mb true true 5.5. false
tk-search p .xxx.xx.xxx _1ft .7mb true true 5.5. false
tk-search p .xxx.xx.xxx _1jz .6mb true true 5.5. false
tk-search p .xxx.xx.xxx _1kt .2mb true true 5.5. true
tk-search p .xxx.xx.xxx _1ku .6kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kv .3kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kw .1kb true true 5.5. true
tk-search r .yyy.yy.yyy _1bm .8mb true true 5.5. false
tk-search r .yyy.yy.yyy _1g2 .3mb true true 5.5. false
tk-search r .yyy.yy.yyy _1ki .2mb true true 5.5. true
tk-search r .yyy.yy.yyy _1ks .7kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kt .2mb true true 5.5. true
tk-search r .yyy.yy.yyy _1ku .9kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kv .8kb true true 5.5. true
tk-search r .xxx.xx.xxx _189 .8mb true true 5.5. false
tk-search r .xxx.xx.xxx _1ed .2mb true true 5.5. false
tk-search r .xxx.xx.xxx _1jd .1mb true true 5.5. false
tk-search r .xxx.xx.xxx _1kr .8mb true true 5.5. true
tk-search r .xxx.xx.xxx _1ks .3kb true true 5.5. true
tk-search r .xxx.xx.xxx _1kt .1kb true true 5.5. true
tk-search r .xxx.xx.xxx _1ku .9kb true true 5.5. true
tk-search r .xxx.xx.xxx _1kv .4kb true true 5.5. true
tk-search r .xxx.xx.xxx _1kw 129kb true true 5.5. true
tk-search r .xxx.xx.xxx _1kx .1kb true true 5.5. true
tk-search p .yyy.yy.yyy _193 .9mb true true 5.5. false
tk-search p .yyy.yy.yyy _1ee .2mb true true 5.5. false
tk-search p .yyy.yy.yyy _1jn .4mb true true 5.5. false
tk-search p .yyy.yy.yyy _1kr .5mb true true 5.5. true
tk-search p .yyy.yy.yyy _1ks .1kb true true 5.5. true
tk-search p .xxx.xx.xxx _1ar .8mb true true 5.5. false
tk-search p .xxx.xx.xxx _1fh .1mb true true 5.5. false
tk-search p .xxx.xx.xxx _1ki .5mb true true 5.5. false
tk-search p .xxx.xx.xxx _1kr .8mb true true 5.5. false
tk-search p .xxx.xx.xxx _1ks .3kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kt .9kb true true 5.5. true
tk-search p .xxx.xx.xxx _1ku .1kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kl .7kb true true 5.5. true
tk-search r .yyy.yy.yyy _1km .4kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kn .3kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kr .8mb true true 5.5. false
tk-search r .yyy.yy.yyy _1ks .9kb true true 5.5. true
tk-search r .yyy.yy.yyy _1kt .1kb true true 5.5. true
tk-search r .xxx.xx.xxx _1a7 .5mb true true 5.5. false
tk-search r .xxx.xx.xxx _1ex .9mb true true 5.5. false
tk-search r .xxx.xx.xxx _1jd .7mb true true 5.5. false
tk-search r .xxx.xx.xxx _1kr .2mb true true 5.5. true
tk-search r .xxx.xx.xxx _1ks .4kb true true 5.5. true
tk-search r .xxx.xx.xxx _1kt .4kb true true 5.5. true
tk-search p .yyy.yy.yyy _1c5 .3mb true true 5.5. false
tk-search p .yyy.yy.yyy _1gl .4mb true true 5.5. false
tk-search p .yyy.yy.yyy _1kh .5mb true true 5.5. true
tk-search p .yyy.yy.yyy _1kr 4mb true true 5.5. true
tk-search p .yyy.yy.yyy _1ks .9kb true true 5.5. true
tk-search p .yyy.yy.yyy _1kt .6kb true true 5.5. true
tk-search p .xxx.xx.xxx _17p 21mb true true 5.5. false
tk-search p .xxx.xx.xxx _1i0 .5mb true true 5.5. false
tk-search p .xxx.xx.xxx _1ki .4mb true true 5.5. true
tk-search p .xxx.xx.xxx _1kr 3mb true true 5.5. true
tk-search p .xxx.xx.xxx _1ks .8kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kt .8kb true true 5.5. true
tk-search p .xxx.xx.xxx _1ku .5kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kv .5kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kw .8kb true true 5.5. true
tk-search p .xxx.xx.xxx _1kx .8kb true true 5.5. true
tk-search r .yyy.yy.yyy _1c5 .3mb true true 5.5. false
tk-search r .yyy.yy.yyy _1hf 10mb true true 5.5. false
tk-search r .yyy.yy.yyy _1kh .1mb true true 5.5. true
tk-search r .yyy.yy.yyy _1kr .6kb true true 5.5. true
tk-search r .yyy.yy.yyy _1ks .1mb true true 5.5. true
tk-search r .yyy.yy.yyy _1kt .8kb true true 5.5. true

上述的cat指令,相当于一个简单的memo,方便用来查看系统状态和数据分布。

elasticsearch【cat API,系统数据】指令汇总的更多相关文章

  1. Unix系统操作指令汇总

    一.目录及文件操作命令 1.1 ls 语法: ls [-RadCxmlnogrtucpFbqisf1] [目录或文件--] 说明: ls 命令列出指定目录下的文件,缺省目录为当前目录 ./,缺省输出顺 ...

  2. Linux系统操作指令汇总

    1.系统配置 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIO ...

  3. MAC系统操作指令汇总

    OSX 的文件系统 OSX 采用的Unix文件系统,所有文件都挂在跟目录 / 下面,所以不在要有Windows 下的盘符概念. 你在桌面上看到的硬盘都挂在 /Volumes 下. 比如接上个叫做 US ...

  4. Windows系统操作指令汇总

    CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本.文件系统版本) 1. appwiz.cpl:程序和功能 2. calc:启动计算器 3. certmgr ...

  5. Elasticsearch cat api的用法

    文章转自:https://blog.csdn.net/wangpei1949/article/details/82287444

  6. elasticsearch REST API方式批量插入数据

    elasticsearch REST API方式批量插入数据 1:ES的服务地址  http://127.0.0.1:9600/_bulk 2:请求的数据体,注意数据的最后一行记得加换行 { &quo ...

  7. [搜索]ElasticSearch Java Api(一) -添加数据创建索引

    转载:http://blog.csdn.net/napoay/article/details/51707023 ElasticSearch JAVA API官网文档:https://www.elast ...

  8. Elasticsearch利用cat api快速查看集群状态、内存、磁盘使用情况

    使用场景 当Elasticsearch集群中有节点挂掉,我们可以去查看集群的日志信息查找错误,不过在查找错误日志之前,我们可以通过elasticsearch的cat api简单判断下各个节点的状态,包 ...

  9. Elasticsearch日志分析系统

    Elasticsearch日志分析系统 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.什么是Elasticsearch 一个采用Restful API标准的高扩展性的和高可用性 ...

随机推荐

  1. @property? @property?说说他身后的事情。

    @property 后面可以有哪些修饰符? 1.线程安全的       aaomic.nonatomic 2.访问权限的       readonly.readwrite 3.内存管理(ARC) as ...

  2. 构造一个简单的Linux系统MenuOS

    陈智威20135125 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 实验指导 ...

  3. std::vector<bool>中的坑

    http://www.cplusplus.com/reference/vector/vector/?kw=vector C++中,vector<bool>为了达到节省内存的目的,专门做了特 ...

  4. ruby on rails 安装

    第一种方案: 1. 下载ruby    Ruby21-x64 2. 1 gem sources --remove http://rubygems.org 2. 2 gem sources -a htt ...

  5. Android开发学习笔记:Intent的简介以及属性的详解【转】

    一.Intent的介绍 Intent的中文意思是“意图,意向”,在Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述 ...

  6. apicloud 解析

    function jiexi(id) { var getTabBarActivityUrl = '/QuestionReport?filter='; var urlParam = {}; ajaxRe ...

  7. CreateFile函数详解

    CreateFile函数详解 CreateFile The CreateFile function creates or opens the following objects and returns ...

  8. a* products

    Experience of black-box testing on set-top-boxes/IP-connected devices, games consoles and tablets ht ...

  9. WebStorm里面配置运行React Native的方案

    以前开发react native项目总是需要打开WebStorm编写代码,Xcode跑项目.显得有点多余. 今天教大家如何直接使用WebStorm这个IDE直接完成编码+运行项目工作.这样就可以不用打 ...

  10. IntelliJ怎么读?

    原来IntelliJ 的正确发音是 Intel  li  J. 周知.