码迷,mamicode.com
首页 > Windows程序 > 详细

ELASTIC API

时间:2017-02-28 19:19:17      阅读:392      评论:0      收藏:0      [点我收藏+]

标签:ldd   host   www   统计信息   heap   简介   配置   特定   time   

运维常用API。

curl -XGET ‘localhost:9200/_cat/indices?v&pretty‘ #查看索引
curl -XGET ‘localhost:9200/_cat/nodes?v&pretty‘ #查看节点状态
curl -XGET ‘localhost:9200/_cluster/health?pretty‘   #查看集群状态
curl -XGET ‘localhost:9200/_nodes/stats/jvm?pretty=true‘   #集群JVM状态

 

CAT API

简介

JSON对于电脑来说是简单且容易分辨的,但是对于人来说,确十分的难以理解,人眼看到ssh终端的时候,喜欢紧凑对齐的文本,cat API旨在满足这一需求。

常用参数:

详细输出

每一个命令后都可加参数v来打开详细输出,例如:

curl -XGET ‘localhost:9200/_cat/master?v&pretty‘

 

查看帮助

每一个命令都可以help来查看用法

curl -XGET ‘localhost:9200/_cat/master?help&pretty‘

 

指定列

你也可以定制只输出你关心的某几列(列名支持简单的通配符,比如以name开头的name*)

curl -XGET ‘localhost:9200/_cat/nodes?h=ip,port,heapPercent,name&pretty‘

 

更改输出单位

cat默认输出是人类友好的格式,例如输出3.5mb而不是3763212,如果你想看详细数据,请使用如下参数

要更改时间单位,请使用time参数

如果你要更改大小单位,请使用size参数

如果你要使用字节单位,请使用bytes参数

例如

curl ‘localhost:9200/_cat/indeces?bytes=b‘

 

更改响应文本

响应为text,json,smile,yaml or cbor

curl ‘192.168.56.10:9200/_cat/indices?bytes=b‘

当前支持的格式(对于?format= 参数): - text (默认) - json - smile - yaml - cbor

你也可以设置"Accept"HTTP header 来指定相应格式例如

curl ‘192.168.56.10:9200/_cat/indices?pretty‘ -H "Accept: application/json"

 

排序

每个命令接收查询字符串参数 s ,该参数为指定参数的值的列进行排序。列通过名称指定,并以逗号分隔的字符串形式提供。默认情况下排序为升序,参数:desc会倒序排列。

curl -XGET ‘localhost:9200/_cat/templates?v&s=order:desc,template&pretty‘

 

cat 别名

aliases显示当前别名的配置信息,包含fileter和routing信息

curl -XGET ‘localhost:9200/_cat/aliases?v&pretty‘

 

cat 显示用量

allocation选项可已把每台es的分片数,索引大小,磁盘用量以及总量等等展示出来(shards disk.indices disk.used disk.avail disk.total disk.percent host ip node)

curl -XGET ‘localhost:9200/_cat/allocation?v&pretty‘

 

cat 记数

若想获得整个集群或者单个索引的文档数,请使用count

curl -XGET ‘localhost:9200/_cat/count?v&pretty‘

curl -XGET ‘localhost:9200/_cat/count/twitter?v&pretty‘

注意,文档数只包含活动文档数量。

 

cat fielddata

展示每个数据节点上的fielddata正在使用多少堆内存

curl -XGET ‘localhost:9200/_cat/fielddata?v&pretty‘

也可以针对某一字段进行查看

curl -XGET ‘localhost:9200/_cat/fielddata?v&fields=body&pretty‘

它也接受逗号分隔

curl -XGET ‘localhost:9200/_cat/fielddata/body,soul?v&pretty‘

 

cat 健康

health类似/_cluster/health,但是比较简洁,一行展示状态。

curl -XGET ‘localhost:9200/_cat/health?v&pretty‘

使用ts禁用时间戳

curl -XGET ‘localhost:9200/_cat/health?v&ts=0&pretty‘

 

cat indices(查看索引)

indices命令提供每个索引的信息。

curl -XGET ‘localhost:9200/_cat/indices/twi*?v&s=index&pretty‘

默认情况下,索引统计将显示所有索引的信息,可以提供特定一个pri标志。

那些索引状态是黄色?

curl -XGET ‘localhost:9200/_cat/indices?v&health=yellow&pretty‘

那个索引拥有最多的文档数

curl -XGET ‘localhost:9200/_cat/indices?v&s=docs.count:desc&pretty‘

每个索引用掉了多少内存

curl -XGET ‘localhost:9200/_cat/indices?v&h=i,tm&s=tm:desc&pretty‘

 

cat master 查看主

master没有任何多余的选项,它只简单的显示出主的id,绑定的地址,和节点名字

curl -XGET ‘localhost:9200/_cat/master?v&pretty‘

 

cat nodeattrs

nodeattrs命令展示节点的自定义属性

curl -XGET ‘localhost:9200/_cat/nodeattrs?v&pretty‘

nodeattrs?h= 可传递指定列,

curl -XGET ‘localhost:9200/_cat/nodeattrs?v&h=name,pid,attr,value&pretty‘

 

cat nodes 查看节点

nodes参数用来展示集群拓扑。

curl -XGET ‘localhost:9200/_cat/nodes?v&pretty‘

我们同样可已用参数nodes?h=来指定显示特定信息。

参数非常的多,而且非常的详细,详见链接。

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html

 

cat pending tasks待处理任务

pending_tasks 以方便的表格形式提供与/_cluster/pending_tasks API相同的信息

curl -XGET ‘localhost:9200/_cat/pending_tasks?v&pretty‘

 

cat plugins 查看插件

plugins可以查看到你集群中每个节点运行的插件的信息

curl -XGET ‘localhost:9200/_cat/plugins?v&s=component&h=name,component,version,description&pretty‘

 

cat recovery

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html

 

cat repositories 查看存储库

repositories 参数显示在集群中注册的快照存储库:

curl -XGET ‘localhost:9200/_cat/repositories?v&pretty‘

 

cat thread pool 查看线程池

默认情况下,返回所有线程池的活动,队列和被拒绝的统计信息。

curl -XGET ‘192.168.99.11:9200/_cat/thread_pool?v&pretty‘

 

cat shards 查看分片信息

顾名思义,shards选项用来查看分片信息,

curl -XGET ‘192.168.99.11:9200/_cat/shards?v&pretty‘

查看指定索引的情况

curl -XGET ‘192.168.99.11:9200/_cat/shards/wiki*?v&pretty‘

 

ELASTIC API

标签:ldd   host   www   统计信息   heap   简介   配置   特定   time   

原文地址:http://www.cnblogs.com/kerwinC/p/6473388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!