我正在尝试使用 Prometheus 从 MariaDB 获取数据。尤其是 Userstat 表。
我有三台机器。在第一个上,我安装了 MariaDB 数据库,在第二个上我安装了 Prometheus,第三个上安装了 Grafana。
我在 MariaDB 上设置了用户状态功能SET GLOBAL userstat=1;
并创建了 mysql_exporter 用户
MariaDB [(none)]> CREATE USER 'exporter'@'444.333.22.111' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'444.333.22.111';
MariaDB [(none)]> FLUSH PRIVILEGES;
接下来我在第二台机器上安装了 Prometheus 和 mysql exporter。我也从存储库和 mysql_exporter 获得了 Prometheus。
我的出口商的路径是:/etc/default/prometheus-mysqld-exporter
并且看起来像:
# By default the connection string will be read from
# $HOME/my.cnf or -config.my-cnf.
# To set a connection string from the environment instead, uncomment the
# following line.
export DATA_SOURCE_NAME="exporter:password@(444.333.22.111:3306)/mysql"
# Set the command-line arguments to pass to the exporter.
# ARGS='-config.my-cnf /etc/mysql/debian.cnf'
-collect.auto_increment.columns
-collect.binlog_size
-collect.info_schema.userstats
-config.my-cnf string
-web.listen-address=0.0.0.0:9104
普罗米修斯.yml:
# Sample config for Prometheus.
global:
scrape_interval: 1s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'example'
# Load and evaluate rules in this file every 'evaluation_interval' seconds.
rule_files:
# - "first.rules"
# - "second.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_timeout: 5s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090', 'localhost:9104']
- job_name: node
# If prometheus-node-exporter is installed, grab stats about the local
# machine by default.
static_configs:
- targets: ['localhost:9100']
不幸的是,它没有做我想做的事,并继续监控我安装了 Prometheus 的机器。任何想法可能是问题所在?提前致谢!