search
场景和视图 视图模板 MySQL Binlog 监控视图

MySQL Binlog 监控视图

简介

展示 MySQLBinlog 的监控指标

前置条件

需安装 DataKit,打开 DataKit 采集源配置文件夹(默认路径为 DataKit 安装目录的 conf.d 文件夹),找到 binlog 文件夹,打开里面的 binlog.conf

配置

打开 DataKit 采集源配置文件夹(默认路径为 DataKit 安装目录的 conf.d 文件夹),找到 mysql 文件夹,打开里面的 mysql.conf

null_int=0
null_float=0.0
[[sources]]
  addr="localhost:3306"
  user="solarops"
  password="Zyadmin123"

  [[sources.databases]]
    db = "test01"
        [[sources.databases.tables]]
          name="t1"
          measurement="mysqlbinlog_t1"
          fields=["booboo"]
          tags=["id"]
          exclude_events=[]

数据库中创建表并执行操作

root@MySQL-01 17:21:  [test01]> desc t1;
+--------+---------+------+-----+---------+----------------+
| Field  | Type    | Null | Key | Default | Extra          |
+--------+---------+------+-----+---------+----------------+
| id     | int(11) | NO   | PRI | NULL    | auto_increment |
| stock  | int(11) | YES  | MUL | NULL    |                |
| hana   | int(11) | YES  | MUL | NULL    |                |
| s_in_h | int(11) | YES  |     | NULL    |                |
| h_in_s | int(11) | YES  |     | NULL    |                |
| new    | int(11) | YES  |     | NULL    |                |
| new2   | int(11) | YES  | UNI | NULL    |                |
| booboo | int(11) | YES  |     | NULL    |                |
+--------+---------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

root@MySQL-01 17:21:  [test01]> insert into t1 set id=41134,stock=1,booboo=100;
Query OK, 1 row affected (0.30 sec)

root@MySQL-01 17:21:  [test01]> insert into t1 set id=41135,stock=1,booboo=101;
Query OK, 1 row affected (0.08 sec)

root@MySQL-01 17:45:  [test01]> update t1 set booboo=0 where id=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

root@MySQL-01 17:45:  [test01]> delete from t1 where id=2;
Query OK, 1 row affected (0.09 sec)

root@MySQL-01 17:45:  [test01]> exit

注意:如果表名或者字段是关键字,请使用单引号进行配置,例如:name='`user`' 或 tags=['`column1`'] 或 fields=['`column0`']

配置好后,重启 DataKit 即可生效

概览

mysqlbinlog