本博文讲述的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. Three.js资源

    学习教程:http://www.hewebgl.com/ 例子:http://threejs.org/

  2. 团队第二周:SRS文档

    项目计划: 对于这次的实验,我们组计划进行一个图书管理系统的项目书写,在第一阶段,对该项目先进行一下规划,总结该项目的注意事项以及实验要求,并加以实施. 下面我先对我们项目的要求坐一下说明: 1定义五 ...

  3. linux中解压缩并安装.tar.gz后缀的文件

    1.解压缩: Linux下以tar.gz为扩展名的软件包,是用tar程序打包并用gzip程序压缩的软件包.要安装这种软件包,需要先对软件包进行解压缩,使用“tar -zxfv filename.tar ...

  4. UVA 820 --- POJ 1273 最大流

    找了好久这两个的区别...UVA820 WA了 好多次.不过以后就做模板了,可以求任意两点之间的最大流. UVA 是无向图,因此可能有重边,POJ 1273是有向图,而且是单源点求最大流,因此改模板的 ...

  5. 最适合和最不适合新手使用的几款 Linux 发行版

    大多数知名的Linux发行版都属于"比较容易使用"这一类.一些观察人士可能会驳斥这个观点,但事实上,说到Linux,大多数并非从事IT或软件开发工作的人会被最容易的使用体验所吸引. ...

  6. 11、Linq的使用

    一.种类 1.Linq to Objects,实现了IEnumerable<T>集合对象的集成查询 2.Linq to sql,针对关系数据库MSSQL的解释查询 3.Linq to En ...

  7. C#获得网卡信息 NetworkInterface IPInterfaceProperties

    System.Net.NetworkInformation下的 1:NetworkInterface类,提供网络适配器的配置和统计信息. 可以通过它检测本机配置了多少网卡,哪些网络连接可用,获得网卡的 ...

  8. Eclipse利用Axis2插件构建Web Service并测试

    在学习Web Service的时候,从网上找到前辈的博客http://www.cnblogs.com/hexinlin/p/3358558.html,并依此文的方法按部就班:编写欲发布的java类He ...

  9. 黑马----JAVA比较器:Comparable和Comparator

    黑马程序员:Java培训.Android培训.iOS培训..Net培训 一.Comparable接口 1.public interface Comparable{ public int compare ...

  10. 关于如何通过json更改背景图片

    今天遇到的问题,突然脑子就不灵光了,平时我们在用jquery更改元素css样式,特别是background的时候,通常用的代码 $("body").css("backgr ...