https://github.com/prometheus/mysqld_exporter
tar -xvf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /app/prometheusnode
vim .my.cnf [client] host=127.0.0.1 user=root password=root
vim /usr/lib/systemd/system/mysqld_exporter.service [Unit] Description=node_exporter Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/app/prometheus/mysqld_exporter/mysqld_exporter --config.my-cnf=/app/prometheus/mysqld_exporter/.my.cnf Restart=on-failure [Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl enable mysqld_exporter.service systemctl start mysqld_exporter.service
#systemctl status mysqld_exporter.service ● mysqld_exporter.service - node_exporter Loaded: loaded (/usr/lib/systemd/system/mysqld_exporter.service; enabled; vendor preset: disabled) Active: active (running) since 一 2019-06-17 00:11:52 CST; 4s ago Docs: https://prometheus.io/ Main PID: 27193 (mysqld_exporter) CGroup: /system.slice/mysqld_exporter.service └─27193 /app/prometheus/mysqld_exporter/mysqld_exporter --config.my-cnf=/app/prometheus/mysqld_exporter/.my.cnf 6月 17 00:11:52 qas-zabbix4 systemd[1]: Started node_exporter. 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Starting mysqld_exporter (version=0.11.0, branch=HEAD, revision=5d7179615...ter.go:206" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Build context (go=go1.10.3, user=root@3d3ff666b0e4, date=20180629-15:00:3...ter.go:207" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Enabled scrapers:" source="mysqld_exporter.go:218" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.global_status" source="mysqld_exporter.go:222" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.global_variables" source="mysqld_exporter.go:222" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.slave_status" source="mysqld_exporter.go:222" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.info_schema.tables" source="mysqld_exporter.go:222" 6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Listening on :9104" source="mysqld_exporter.go:232" Hint: Some lines were ellipsized, use -l to show in full.
http://172.16.8.59:9104/metrics
mysql
vim /app/prometheus/cfg/prometheus.yml - job_name: 'mysqld' file_sd_configs: - files: ['/app/prometheus/sd_cfg/mysqld.yml'] refresh_interval: 5s
vim /app/prometheus/sd_cfg/mysqld.yml - targets: ['172.16.8.59:9104'] labels: name: mysql
systemctl restart prometheus.service