Skip to content

Commit

Permalink
add mysql metrics performance, query_cache, handler and more (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 committed Feb 13, 2023
1 parent c8e685d commit 9fee426
Showing 1 changed file with 199 additions and 9 deletions.
208 changes: 199 additions & 9 deletions manager/src/main/resources/define/app/app-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,59 @@ metrics:
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';
url: ^_^url^_^

- name: cache
- name: performance
priority: 1
fields:
- field: questions
type: 0
- field: qps
type: 0
unit: '次/s'
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
aliasFields:
- uptime
- questions
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- qps=uptime / questions
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
sql: show global status where Variable_name = 'questions' or Variable_name = 'uptime';
url: ^_^url^_^

- name: query_cache
priority: 1
fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: query_cache_hit_rate
type: 0
unit: '%'
- field: cache_hits
- field: hits
type: 0
- field: inserts
type: 0
- field: not_cached
type: 0
- field: queries_in_cache
type: 0
- field: cache_inserts
- field: prunes
type: 0
- field: cache_free_blocks
type: 0
- field: cache_free_memory
- field: free_memory
type: 0
unit: KB
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
Expand All @@ -171,14 +210,20 @@ metrics:
- Qcache_inserts
- Qcache_free_blocks
- Qcache_free_memory
- Qcache_not_cached
- Qcache_queries_in_cache
- Qcache_lowmem_prunes
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- query_cache_hit_rate= (Qcache_hits + 1) / (Qcache_hits + Qcache_inserts + 1) * 100
- cache_hits=Qcache_hits
- cache_inserts=Qcache_inserts
- hits=Qcache_hits
- inserts=Qcache_inserts
- cache_free_blocks=Qcache_free_blocks
- cache_free_memory=Qcache_free_memory
- free_memory=Qcache_free_memory
- not_cached=Qcache_not_cached
- queries_in_cache=Qcache_queries_in_cache
- prunes=Qcache_lowmem_prunes
units:
- cache_free_memory=B->KB
protocol: jdbc
Expand Down Expand Up @@ -217,6 +262,9 @@ metrics:
- field: innodb_buffer_hit_rate
type: 0
unit: '%'
- field: innodb_buffer_pool_size
type: 0
unit: KB
aliasFields:
- Innodb_data_reads
- Innodb_data_writes
Expand All @@ -225,6 +273,7 @@ metrics:
- Innodb_buffer_pool_read_requests
- Innodb_buffer_pool_read_ahead
- Innodb_buffer_pool_reads
- Innodb_buffer_pool_size
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
Expand All @@ -233,22 +282,163 @@ metrics:
- innodb_data_writes=Innodb_data_writes
- innodb_data_read=Innodb_data_read
- innodb_data_written=Innodb_data_written
- innodb_buffer_pool_size=Innodb_buffer_pool_size
units:
- innodb_data_read=B->KB
- innodb_data_written=B->KB
- innodb_buffer_pool_size=B->KB
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mariadb
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
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';
url: ^_^url^_^

- name: handler
priority: 2
fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: handler_commit
type: 0
- field: handler_delete
type: 0
- field: handler_write
type: 0
- field: handler_update
type: 0
- field: handler_discover
type: 0
- field: handler_prepare
type: 0
- field: handler_read_first
type: 0
- field: handler_read_rnd
type: 0
- field: handler_read_next
type: 0
- field: handler_read_rnd_next
type: 0
- field: handler_read_key
type: 0
- field: handler_external_lock
type: 0
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
sql: show global status like 'Handler%';
url: ^_^url^_^

- name: connection
priority: 2
fields:
- field: max_connections
type: 0
- field: connections
type: 0
- field: max_used_connections
type: 0
- field: aborted_connects
type: 0
- field: aborted_clients
type: 0
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
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%';
url: ^_^url^_^

- name: thread
priority: 2
fields:
- field: threads_created
type: 0
- field: threads_connected
type: 0
- field: threads_cached
type: 0
- field: threads_running
type: 0
- field: thread_cache_size
type: 0
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
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';
url: ^_^url^_^

- name: table_cache
priority: 2
fields:
- field: table_open_cache
type: 0
- field: table_open_cache_miss_ratio
type: 0
unit: '%'
aliasFields:
- table_open_cache
- table_open_cache_misses
- table_open_cache_hits
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- table_open_cache_miss_ratio= table_open_cache_misses / table_open_cache * 100
- table_open_cache=table_open_cache
protocol: jdbc
jdbc:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# 端口
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
# SQL查询方式: oneRow, multiRow, columns
queryType: columns
# sql
sql: show global status where Variable_name like 'innodb%';
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';
url: ^_^url^_^

0 comments on commit 9fee426

Please sign in to comment.