0%

索引监控

索引监控

elasticsearch提供了接口来监控索引的状态,包括索引的统计信息、碎片信息、恢复的状态以及分片信息

索引统计

索引统计提供了索引中不同内容的统计数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// 统计所有索引
GET _stats

// 统计某个索引
GET testmapping/_stats


{
"_all": {
"primaries": {
"docs": { // 文档数据
"count": 0,
"deleted": 0
},
"store": { // 索引的大小
"size_in_bytes": 261
},
"indexing": { // 索引统计数据
"index_total": 0,
"index_time_in_millis": 0,
"index_current": 0,
"index_failed": 0,
"delete_total": 0,
"delete_time_in_millis": 0,
"delete_current": 0,
"noop_update_total": 0,
"is_throttled": false,
"throttle_time_in_millis": 0
},
"get": { // 获取统计数据
"total": 0,
"time_in_millis": 0,
"exists_total": 0,
"exists_time_in_millis": 0,
"missing_total": 0,
"missing_time_in_millis": 0,
"current": 0
},
"search": { // 搜索统计数据
"open_contexts": 0,
"query_total": 1,
"query_time_in_millis": 0,
"query_current": 0,
"fetch_total": 1,
"fetch_time_in_millis": 0,
"fetch_current": 0,
"scroll_total": 0,
"scroll_time_in_millis": 0,
"scroll_current": 0,
"suggest_total": 0,
"suggest_time_in_millis": 0,
"suggest_current": 0
},
"merges": { //混合统计数据
"current": 0,
"current_docs": 0,
"current_size_in_bytes": 0,
"total": 0,
"total_time_in_millis": 0,
"total_docs": 0,
"total_size_in_bytes": 0,
"total_stopped_time_in_millis": 0,
"total_throttled_time_in_millis": 0,
"total_auto_throttle_in_bytes": 20971520
},
"refresh": { //刷新统计数据
"total": 5,
"total_time_in_millis": 2,
"listeners": 0
},
"flush": { // 冲洗统计数据
"total": 1,
"periodic": 0,
"total_time_in_millis": 4
},
"warmer": {
"current": 0,
"total": 2,
"total_time_in_millis": 0
},
"query_cache": {
"memory_size_in_bytes": 0,
"total_count": 0,
"hit_count": 0,
"miss_count": 0,
"cache_size": 0,
"cache_count": 0,
"evictions": 0
},
"fielddata": { // 字段数据统计数据
"memory_size_in_bytes": 0,
"evictions": 0
},
"completion": { // 完成建议统计数据
"size_in_bytes": 0
},
"segments": { // 分片信息
"count": 0,
"memory_in_bytes": 0,
"terms_memory_in_bytes": 0,
"stored_fields_memory_in_bytes": 0,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 0,
"points_memory_in_bytes": 0,
"doc_values_memory_in_bytes": 0,
"index_writer_memory_in_bytes": 0,
"version_map_memory_in_bytes": 0,
"fixed_bit_set_memory_in_bytes": 0,
"max_unsafe_auto_id_timestamp": -1,
"file_sizes": {}
},
"translog": { // 事务日志统计数据
"operations": 0,
"size_in_bytes": 110,
"uncommitted_operations": 0,
"uncommitted_size_in_bytes": 55,
"earliest_last_modified_age": 14932257
},
"request_cache": { // 分片请求缓存统计数据
"memory_size_in_bytes": 0,
"evictions": 0,
"hit_count": 0,
"miss_count": 0
},
"recovery": { // 索引恢复信息
"current_as_source": 0,
"current_as_target": 0,
"throttle_time_in_millis": 0
}
}
}
}

也可以只查询部分监控

1
GET testmapping/_stats/translog,store

索引分片信息

其在_stats中也包含有分片信息,不过又单独拿出来了一个接口,提供更详细的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 获取某个索引的分片信息
GET tm/_segments

// 获取所有索引的分片信息
GET _segments


{
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"indices": {
"testmapping": {
"shards": {
"0": [
{
"routing": {
"state": "STARTED",
"primary": true,
"node": "ZUkF5AgmR9WMMDHxPj4oMg"
},
"num_committed_segments": 0,
"num_search_segments": 0,
"segments": {}
}
]
}
}
}
}

索引恢复信息

其在_stats中也包含有恢复信息,不过又单独拿出来了一个接口,提供更详细的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 获取某个索引的恢复信息
GET testmapping/_recovery

// 获取所有索引的恢复信息
GET _recovery


{
"testmapping": {
"shards": [
{
"id": 0,
"type": "EXISTING_STORE", // 恢复类型:包括存储、快照、复制、迁移
"stage": "DONE", // 恢复阶段:包括初始化(恢复还没开始)、索引(读取索引元字段并且从源到目的地复制字节)、开始(启动恢复)、事务日志(重做事务日志)、完成(清理)、结束
"primary": true, // 如果是主分片,则为true
"start_time_in_millis": 1653271499488,
"stop_time_in_millis": 1653271500013,
"total_time_in_millis": 525,
"source": { // 恢复源
"bootstrap_new_history_uuid": false
},
"target": { // 目标节点
"id": "ZUkF5AgmR9WMMDHxPj4oMg",
"host": "192.168.1.220",
"transport_address": "192.168.1.220:9300",
"ip": "192.168.1.220",
"name": "ZUkF5Ag"
},
"index": { // 物理索引恢复的统计数据
"size": {
"total_in_bytes": 230,
"reused_in_bytes": 230,
"recovered_in_bytes": 0,
"percent": "100.0%"
},
"files": {
"total": 1,
"reused": 1,
"recovered": 0,
"percent": "100.0%"
},
"total_time_in_millis": 80,
"source_throttle_time_in_millis": 0,
"target_throttle_time_in_millis": 0
},
"translog": { // 事务日志恢复的统计数据
"recovered": 0,
"total": 0,
"percent": "100.0%",
"total_on_start": 0,
"total_time_in_millis": 310
},
"verify_index": {
"check_index_time_in_millis": 0,
"total_time_in_millis": 0
}
}
]
}
}

索引分片存储

提供索引分片副本的存储信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
GET testmapping/_shard_stores


{
"indices": {
"testmapping": {
"shards": {
"0": {
"stores": [
{
"ZUkF5AgmR9WMMDHxPj4oMg": {
"name": "ZUkF5Ag",
"ephemeral_id": "9DSEd6yyQDukUEcDkRSmDw",
"transport_address": "192.168.1.220:9300",
"attributes": {
"ml.machine_memory": "33465151488",
"xpack.installed": "true",
"ml.max_open_jobs": "20",
"ml.enabled": "true"
}
},
"allocation_id": "x_VCUfCDQaCDOeHXiTshyQ",
"allocation": "primary"
}
]
}
}
}
}
}

欢迎关注我的其它发布渠道