add mysql readme

This commit is contained in:
Ulric Qin 2022-06-13 13:41:02 +08:00
parent ace9c10af2
commit b140504002
3 changed files with 102 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# docker plugin
# docker
forked from telegraf/inputs.docker

96
inputs/mysql/README.md Normal file
View File

@ -0,0 +1,96 @@
# mysql
mysql 监控采集插件,核心原理就是连到 mysql 实例,执行一些 sql解析输出内容整理为监控数据上报。
## Configuration
```toml
# # collect interval
# interval = 15
# 要监控 MySQL首先要给出要监控的MySQL的连接地址、用户名、密码
[[instances]]
address = "127.0.0.1:3306"
username = "root"
password = "1234"
# # set tls=custom to enable tls
# parameters = "tls=false"
# 通过 show global status监控mysql默认抓取一些基础指标
# 如果想抓取更多global status的指标把下面的配置设置为true
extra_status_metrics = true
# 通过show global variables监控mysql的全局变量默认抓取一些常规的
# 常规的基本够用了扩展的部分默认不采集下面的配置设置为false
extra_innodb_metrics = false
# 监控processlist关注较少默认不采集
gather_processlist_processes_by_state = false
gather_processlist_processes_by_user = false
# 监控各个数据库的磁盘占用大小
gather_schema_size = true
# 监控所有的table的磁盘占用大小
gather_table_size = false
# 是否采集系统表的大小通过不用所以默认设置为false
gather_system_table_size = false
# 通过 show slave status监控slave的情况比较关键所以默认采集
gather_slave_status = true
# # timeout
# timeout_seconds = 3
# # interval = global.interval * interval_times
# interval_times = 1
# 如果要复用Grafana的大盘Grafana的大盘一般使用instance标识的
# 建议为mysql实例附一个instance的标签
# important! use global unique string to specify instance
# labels = { instance="n9e-10.2.3.4:3306" }
## Optional TLS Config
# use_tls = false
# tls_min_version = "1.2"
# tls_ca = "/etc/categraf/ca.pem"
# tls_cert = "/etc/categraf/cert.pem"
# tls_key = "/etc/categraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = true
# 自定义SQL指定SQL、返回的各个列那些是作为metric哪些是作为label
# [[instances.queries]]
# mesurement = "users"
# metric_fields = [ "total" ]
# label_fields = [ "service" ]
# # field_to_append = ""
# timeout = "3s"
# request = '''
# select 'n9e' as service, count(*) as total from n9e_v5.users
# '''
```
## 监控多个实例
大家最常问的问题是如何监控多个mysql实例实际大家对toml配置学习一下就了解了`[[instances]]` 部分表示数组,是可以出现多个的,所以,举例:
```toml
[[instances]]
address = "10.2.3.6:3306"
username = "root"
password = "1234"
labels = { instance="n9e-10.2.3.6:3306" }
[[instances]]
address = "10.2.6.9:3306"
username = "root"
password = "1234"
labels = { instance="zbx-10.2.6.9:3306" }
```
## 监控大盘和告警规则
本 README 的同级目录,大家可以看到 dashboard.json 就是监控大盘导入夜莺就可以使用alerts.json 是告警规则,也是导入夜莺就可以使用。

View File

@ -41,4 +41,8 @@ password = "s3cret"
# tls_key = "/etc/categraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = true
```
```
## 监控大盘
本 README 文件的同级目录下放置了用于 Tomcat 的 dashboard.json大家可以导入使用。