上一篇文章如何監(jiān)控Elasticsearch主要描述了對于Es服務(wù)器應(yīng)該監(jiān)控哪些指標(biāo)锨阿。本文旨在介紹es api中的各統(tǒng)計指標(biāo)含義屋讶。
Elasticsearch’s RESTful API + JSON
默認(rèn)情況下朋沮,Elasticsearch在9200端口上提供了restful http服務(wù)菊卷,返回集群轧房,節(jié)點拌阴,索引狀況的JSON結(jié)果。主要有五個HTTP REST API可用于監(jiān)視Elasticsearch:
- Cluster Health API
- Cluster Stats API
- Node Stats API
- Index Stats API
- Pending Tasks API
下面的表格總結(jié)了上一篇文章中提到搜索性能奶镶,索引性能迟赃,內(nèi)存性能陪拘,網(wǎng)絡(luò)性能對應(yīng)的ES API。其中有些性能數(shù)據(jù)是從多個維度描述的纤壁,比如搜索性能在節(jié)點維度和索引維度都有提供左刽。
Metric category | Availability |
---|---|
Search performance metrics | Node Stats API, Index Stats API |
Indexing performance metrics | Node Stats API, Index Stats API |
Memory and garbage collection | Node Stats API, Cluster Stats API |
Network metrics | Node Stats API |
Cluster health and node availability | Cluster Health API |
Resource saturation and errors | Node Stats API, Index Stats API, Cluster Stats API, Pending Tasks API |
(一)Cluster Health API
Cluster Health API提供了描述集群健康狀態(tài)的JSON對象數(shù)據(jù)。
API接口:
GET _cluster/health
返回結(jié)果JSON:
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 11,
"active_shards": 11,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 10,
"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": 52.38095238095239
}
-
status
一共有3個狀態(tài):green
表示所有主分片及備份分片都分配好了酌媒,集群100%健康欠痴。yellow
表示所有主分片都分配好了,但至少有一個備份分片未分配秒咨。數(shù)據(jù)沒有丟失喇辽,搜索結(jié)果是完整的。但高可用性會缺失雨席,存在丟失數(shù)據(jù)風(fēng)險菩咨,以黃色表示警告。red
表示至少有一個主分片未分配陡厘,并且這個主分片的所有分片都丟失了抽米。數(shù)據(jù)已經(jīng)丟失了,搜索結(jié)果不完整糙置,并且往這個分片索引數(shù)據(jù)會發(fā)生異常云茸。 -
number_of_nodes
和number_of_data_nodes
,從名字就可以知道分別是節(jié)點數(shù)和數(shù)據(jù)節(jié)點數(shù)谤饭。 -
active_primary_shards
标捺,集群中所有index的主分片數(shù)量的總和。 -
active_shards
揉抵,集群中所有index的分片數(shù)量的總和宜岛,包括備份分片。 -
relocating_shards
功舀,正在被移動的分片數(shù)量萍倡。通常為0,在集群rebalance的時候會有變化辟汰。
(二)Cluster Stats API
Cluster Stats API提供了集群維度的信息列敲。基本上是Node Stats API的數(shù)據(jù)的總和帖汞。雖然沒有每個節(jié)點的詳細信息戴而,但是可以讓你快速了解掌握整個集群當(dāng)前的運行狀態(tài)。
API接口:
GET _cluster/stats
{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "elasticsearch",
"timestamp": 1500175210218,
"status": "yellow",
"indices": {
"count": 11,
"shards": {...},
"docs": {...},
"store": {...},
"fielddata": {...},
"query_cache": {...},
"completion": {...},
"segments": {...}
},
"nodes": {
"count": {...},
"versions": [...],
"os": {...},
"process": {...},
"jvm": {...},
"fs": {...},
"plugins": [...],
"network_types": {...}
}
}
對于indices和nodes內(nèi)部屬性的含義會在Node Stats API里介紹
(三)Node Stats API
Node Stats API是一個非常有用的API翩蘸,用于監(jiān)控集群每臺服務(wù)器的狀態(tài)所意。它統(tǒng)計了我們想要監(jiān)控的主要的那些指標(biāo),包括了我們上一篇列舉的大部分指標(biāo)。
API接口:
GET _nodes/stats (或者指定node獲取 _nodes/node1,node2/stats)
{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "elasticsearch",
"nodes": {
"SdRLvOO7RKSiaBW_hmwvZg": {
"name": "node1",
"indices": {...},
"os": {...},
"process": {...},
"jvm": {...},
"thread_pool": {...},
"fs": {...},
"transport": {...},
"http": {...}
}
...
}
}
- 查詢性能指標(biāo)扶踊,前綴indices.search.*的指標(biāo)
-
indices.search.query_total
查詢總量 -
indices.search.query_time_in_millis
查詢總耗時 -
indices.search.query_current
正在處理的查詢量 -
indices.search.fetch_total
查詢的第二階段fetch總量 -
indices.search.fetch_time_in_millis
fetch耗時 -
indices.search.fetch_current
正在處理的fetch數(shù)量
-
- 索引性能指標(biāo)泄鹏,前綴indices.indexing.* ,indices.refresh.* 秧耗,indices.flush.* 的指標(biāo)
-
indices.indexing.index_total
索引總量 -
indices.indexing.index_time_in_millis
索引耗時 -
indices.indexing.index_current
正在處理的索引量 -
indices.refresh.total
刷新內(nèi)存總量 -
indices.refresh.total_time_in_millis
刷新內(nèi)存耗時 -
indices.flush.total
同步磁盤總量 -
indices.flush.total_time_in_millis
同步磁盤耗時
-
- Cache性能指標(biāo)备籽,前綴indices.query_cache.* ,indices.fielddata.* 分井,indices.request_cache.* 的指標(biāo)车猬。fielddata可能會成為內(nèi)存消耗大戶,需要特別注意
-
indices.query_cache.memory_size_in_bytes
查詢緩存大小 -
indices.query_cache.evictions
查詢緩存剔除大小 -
indices.fielddata.memory_size_in_bytes
fielddata緩存大小 -
indices.fielddata.evictions
fielddata緩存剔除大小 -
indices.request_cache.memory_size_in_bytes
所有請求緩存大小 -
indices.request_cache.evictions
所有請求緩存剔除大小
-
- os指標(biāo)
-
os.cpu.percent
系統(tǒng)CPU使用百分比 -
os.cpu.load_average.1m
系統(tǒng)CPU 1分鐘平均load -
os.cpu.load_average.5m
系統(tǒng)CPU 5分鐘平均load -
os.cpu.load_average.15m
系統(tǒng)CPU 15分鐘平均load -
os.mem.free_percent
系統(tǒng)內(nèi)存可用百分比 -
os.mem.used_percent
系統(tǒng)內(nèi)存已使用百分比 -
os.mem.total_in_bytes
系統(tǒng)內(nèi)存總大小 -
os.mem.free_in_bytes
系統(tǒng)內(nèi)存可用大小 -
os.mem.used_in_bytes
系統(tǒng)內(nèi)存已使用大小 -
os.swap.total_in_bytes
系統(tǒng)swap總大小 -
os.swap.free_in_bytes
系統(tǒng)swap可用大小 -
os.swap.used_in_bytes
系統(tǒng)swap已使用大小
-
- process指標(biāo)尺锚,專用與es jvm進程的資源消耗指標(biāo)
-
process.cpu.percent
進程CPU使用百分比 -
process.cpu.total_in_millis
進程CPU使用時間 -
process.mem.total_virtual_in_bytes
進程可用虛擬內(nèi)存大小 -
process.open_file_descriptors
進程打開文件句柄數(shù) -
process.max_file_descriptors
進程可用句柄數(shù)
-
- JVM性能指標(biāo)珠闰,前綴jvm.*的指標(biāo),內(nèi)存使用及GC指標(biāo)
-
jvm.gc.collectors.young.collection_count
young gc 大小 -
jvm.gc.collectors.young.collection_time_in_millis
young gc 耗時 -
jvm.gc.collectors.old.collection_count
old gc 大小 -
jvm.gc.collectors.old.collection_time_in_millis
old gc 耗時 -
jvm.mem.heap_used_percent
內(nèi)存使用百分比 -
jvm.mem.heap_used_in_bytes
內(nèi)存使用量 -
jvm.mem.heap_committed_in_bytes
內(nèi)存占用量
-
- 線程池性能指標(biāo)瘫辩,前綴thread_pool.*的指標(biāo)
-
thread_pool.bulk.queue
thread_pool.index.queue
thread_pool.search.queue
thread_pool.merge.queue
各隊列長度 -
thread_pool.bulk.rejected
thread_pool.index.rejected
thread_pool.search.rejected
thread_pool.merge.rejected
各隊列溢出量(未執(zhí)行铸磅,被放棄)
-
- 文件系統(tǒng)指標(biāo)
-
fs.total.total_in_bytes
數(shù)據(jù)目錄總大小 -
fs.total.free_in_bytes
數(shù)據(jù)目錄剩余大小 -
fs.total.vailable_in_bytes
數(shù)據(jù)目錄可用大小
-
- 集群通信指標(biāo)
-
transport.rx_count
集群通信中接收的數(shù)據(jù)包總數(shù) -
transport.rx_size_in_bytes
集群通信中接收的數(shù)據(jù)的總大小 -
transport.tx_count
集群通信中發(fā)送的數(shù)據(jù)包總數(shù) -
transport.tx_size_in_bytes
集群通信中發(fā)送的數(shù)據(jù)的總大小 -
transport.server_open
為集群通信打開的連接數(shù)
-