Elasticsearch:6.API简单使用
2019-08-16 本文已影响0人
小六的昵称已被使用
## 要启用表头,添加 ?v 参数即可
GET /_cat/health?v
## 查看某 API 支持的更多指标(添加 ?help)
GET /_cat/nodes?help
## Elasticsearch Reference
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
1.列出所有可用 API
GET /_cat
=^.^=
## 获取所有节点磁盘分配情况
/_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.健康检查
GET /_cat/health
1563348864 07:34:24 ELK-Cluster green 4 3 1140 571 0 0 0 0 - 100.0%
## 要启用表头,添加 ?v 参数即可
GET /_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
1563348910 07:35:10 ELK-Cluster green 4 3 1140 571 0 0 0 0 - 100.0%
3.集群内节点统计
GET /_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.50.14 45 99 18 1.46 2.49 2.81 mdi * elk-01
192.168.50.17 40 90 3 0.06 0.14 0.11 - - kibana
192.168.50.16 49 99 10 1.61 2.33 2.51 mdi - elk-03
192.168.50.15 71 99 10 1.04 1.62 2.38 mdi - elk-02
## 查看指定信息
GET /_cat/nodes?v&h=ip,port,heapPercent,heapMax
ip port heapPercent heapMax
192.168.50.14 9300 64 7.8gb
192.168.50.17 9300 42 3.8gb
192.168.50.16 9300 63 7.8gb
192.168.50.15 9300 48 7.8gb
4.通过添加 ?bytes=b 关闭人类可读的数字格式化
curl '192.168.50.17:9200/_cat/indices?bytes=b' | sort -rnk8 | grep -v marvel
GET /_cat/indices?bytes=b
5.获取集群健康状态
GET _cluster/health
{
"cluster_name" : "ELK-Cluster",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 4,
"number_of_data_nodes" : 3,
"active_primary_shards" : 571,
"active_shards" : 1140,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}