Skip to content

Commit 9fee426

Browse files
authored
add mysql metrics performance, query_cache, handler and more (#8)
1 parent c8e685d commit 9fee426

File tree

1 file changed

+199
-9
lines changed

1 file changed

+199
-9
lines changed

manager/src/main/resources/define/app/app-mysql.yml

+199-9
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,59 @@ metrics:
149149
sql: show global status where Variable_name like 'thread%' or Variable_name = 'com_select' or Variable_name = 'com_insert' or Variable_name = 'com_update' or Variable_name = 'com_delete' or Variable_name = 'com_commit' or Variable_name = 'com_rollback' or Variable_name = 'questions' or Variable_name = 'uptime';
150150
url: ^_^url^_^
151151

152-
- name: cache
152+
- name: performance
153+
priority: 1
154+
fields:
155+
- field: questions
156+
type: 0
157+
- field: qps
158+
type: 0
159+
unit: '次/s'
160+
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
161+
aliasFields:
162+
- uptime
163+
- questions
164+
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
165+
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
166+
calculates:
167+
- qps=uptime / questions
168+
protocol: jdbc
169+
jdbc:
170+
# 主机host: ipv4 ipv6 域名
171+
host: ^_^host^_^
172+
# 端口
173+
port: ^_^port^_^
174+
platform: mysql
175+
username: ^_^username^_^
176+
password: ^_^password^_^
177+
database: ^_^database^_^
178+
timeout: ^_^timeout^_^
179+
# SQL查询方式: oneRow, multiRow, columns
180+
queryType: columns
181+
# sql
182+
sql: show global status where Variable_name = 'questions' or Variable_name = 'uptime';
183+
url: ^_^url^_^
184+
185+
- name: query_cache
153186
priority: 1
154187
fields:
155188
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
156189
- field: query_cache_hit_rate
157190
type: 0
158191
unit: '%'
159-
- field: cache_hits
192+
- field: hits
193+
type: 0
194+
- field: inserts
195+
type: 0
196+
- field: not_cached
197+
type: 0
198+
- field: queries_in_cache
160199
type: 0
161-
- field: cache_inserts
200+
- field: prunes
162201
type: 0
163202
- field: cache_free_blocks
164203
type: 0
165-
- field: cache_free_memory
204+
- field: free_memory
166205
type: 0
167206
unit: KB
168207
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
@@ -171,14 +210,20 @@ metrics:
171210
- Qcache_inserts
172211
- Qcache_free_blocks
173212
- Qcache_free_memory
213+
- Qcache_not_cached
214+
- Qcache_queries_in_cache
215+
- Qcache_lowmem_prunes
174216
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
175217
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
176218
calculates:
177219
- query_cache_hit_rate= (Qcache_hits + 1) / (Qcache_hits + Qcache_inserts + 1) * 100
178-
- cache_hits=Qcache_hits
179-
- cache_inserts=Qcache_inserts
220+
- hits=Qcache_hits
221+
- inserts=Qcache_inserts
180222
- cache_free_blocks=Qcache_free_blocks
181-
- cache_free_memory=Qcache_free_memory
223+
- free_memory=Qcache_free_memory
224+
- not_cached=Qcache_not_cached
225+
- queries_in_cache=Qcache_queries_in_cache
226+
- prunes=Qcache_lowmem_prunes
182227
units:
183228
- cache_free_memory=B->KB
184229
protocol: jdbc
@@ -217,6 +262,9 @@ metrics:
217262
- field: innodb_buffer_hit_rate
218263
type: 0
219264
unit: '%'
265+
- field: innodb_buffer_pool_size
266+
type: 0
267+
unit: KB
220268
aliasFields:
221269
- Innodb_data_reads
222270
- Innodb_data_writes
@@ -225,6 +273,7 @@ metrics:
225273
- Innodb_buffer_pool_read_requests
226274
- Innodb_buffer_pool_read_ahead
227275
- Innodb_buffer_pool_reads
276+
- Innodb_buffer_pool_size
228277
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
229278
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
230279
calculates:
@@ -233,22 +282,163 @@ metrics:
233282
- innodb_data_writes=Innodb_data_writes
234283
- innodb_data_read=Innodb_data_read
235284
- innodb_data_written=Innodb_data_written
285+
- innodb_buffer_pool_size=Innodb_buffer_pool_size
236286
units:
237287
- innodb_data_read=B->KB
238288
- innodb_data_written=B->KB
289+
- innodb_buffer_pool_size=B->KB
239290
protocol: jdbc
240291
jdbc:
241292
# 主机host: ipv4 ipv6 域名
242293
host: ^_^host^_^
243294
# 端口
244295
port: ^_^port^_^
245-
platform: mariadb
296+
platform: mysql
297+
username: ^_^username^_^
298+
password: ^_^password^_^
299+
database: ^_^database^_^
300+
timeout: ^_^timeout^_^
301+
# SQL查询方式: oneRow, multiRow, columns
302+
queryType: columns
303+
# sql
304+
sql: select variable_name, variable_value from information_schema.global_status WHERE Variable_name like 'innodb%' UNION select variable_name, variable_value from information_schema.global_variables where Variable_name = 'innodb_buffer_pool_size';
305+
url: ^_^url^_^
306+
307+
- name: handler
308+
priority: 2
309+
fields:
310+
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
311+
- field: handler_commit
312+
type: 0
313+
- field: handler_delete
314+
type: 0
315+
- field: handler_write
316+
type: 0
317+
- field: handler_update
318+
type: 0
319+
- field: handler_discover
320+
type: 0
321+
- field: handler_prepare
322+
type: 0
323+
- field: handler_read_first
324+
type: 0
325+
- field: handler_read_rnd
326+
type: 0
327+
- field: handler_read_next
328+
type: 0
329+
- field: handler_read_rnd_next
330+
type: 0
331+
- field: handler_read_key
332+
type: 0
333+
- field: handler_external_lock
334+
type: 0
335+
protocol: jdbc
336+
jdbc:
337+
# 主机host: ipv4 ipv6 域名
338+
host: ^_^host^_^
339+
# 端口
340+
port: ^_^port^_^
341+
platform: mysql
342+
username: ^_^username^_^
343+
password: ^_^password^_^
344+
database: ^_^database^_^
345+
timeout: ^_^timeout^_^
346+
# SQL查询方式: oneRow, multiRow, columns
347+
queryType: columns
348+
# sql
349+
sql: show global status like 'Handler%';
350+
url: ^_^url^_^
351+
352+
- name: connection
353+
priority: 2
354+
fields:
355+
- field: max_connections
356+
type: 0
357+
- field: connections
358+
type: 0
359+
- field: max_used_connections
360+
type: 0
361+
- field: aborted_connects
362+
type: 0
363+
- field: aborted_clients
364+
type: 0
365+
protocol: jdbc
366+
jdbc:
367+
# 主机host: ipv4 ipv6 域名
368+
host: ^_^host^_^
369+
# 端口
370+
port: ^_^port^_^
371+
platform: mysql
372+
username: ^_^username^_^
373+
password: ^_^password^_^
374+
database: ^_^database^_^
375+
timeout: ^_^timeout^_^
376+
# SQL查询方式: oneRow, multiRow, columns
377+
queryType: columns
378+
# sql
379+
sql: select variable_name, variable_value from information_schema.global_status WHERE Variable_name like '%connect%' or Variable_name = 'Aborted_clients' UNION select variable_name, variable_value from information_schema.global_variables where Variable_name like '%connect%';
380+
url: ^_^url^_^
381+
382+
- name: thread
383+
priority: 2
384+
fields:
385+
- field: threads_created
386+
type: 0
387+
- field: threads_connected
388+
type: 0
389+
- field: threads_cached
390+
type: 0
391+
- field: threads_running
392+
type: 0
393+
- field: thread_cache_size
394+
type: 0
395+
protocol: jdbc
396+
jdbc:
397+
# 主机host: ipv4 ipv6 域名
398+
host: ^_^host^_^
399+
# 端口
400+
port: ^_^port^_^
401+
platform: mysql
402+
username: ^_^username^_^
403+
password: ^_^password^_^
404+
database: ^_^database^_^
405+
timeout: ^_^timeout^_^
406+
# SQL查询方式: oneRow, multiRow, columns
407+
queryType: columns
408+
# sql
409+
sql: select variable_name, variable_value from information_schema.global_status WHERE Variable_name like 'thread%' UNION select variable_name, variable_value from information_schema.global_variables where Variable_name = 'thread_cache_size';
410+
url: ^_^url^_^
411+
412+
- name: table_cache
413+
priority: 2
414+
fields:
415+
- field: table_open_cache
416+
type: 0
417+
- field: table_open_cache_miss_ratio
418+
type: 0
419+
unit: '%'
420+
aliasFields:
421+
- table_open_cache
422+
- table_open_cache_misses
423+
- table_open_cache_hits
424+
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
425+
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
426+
calculates:
427+
- table_open_cache_miss_ratio= table_open_cache_misses / table_open_cache * 100
428+
- table_open_cache=table_open_cache
429+
protocol: jdbc
430+
jdbc:
431+
# 主机host: ipv4 ipv6 域名
432+
host: ^_^host^_^
433+
# 端口
434+
port: ^_^port^_^
435+
platform: mysql
246436
username: ^_^username^_^
247437
password: ^_^password^_^
248438
database: ^_^database^_^
249439
timeout: ^_^timeout^_^
250440
# SQL查询方式: oneRow, multiRow, columns
251441
queryType: columns
252442
# sql
253-
sql: show global status where Variable_name like 'innodb%';
443+
sql: select variable_name, variable_value from information_schema.global_status WHERE Variable_name like 'table_%' UNION select variable_name, variable_value from information_schema.global_variables where Variable_name = 'table_open_cache';
254444
url: ^_^url^_^

0 commit comments

Comments
 (0)