1.下载MySQL的exporter
下载地址:https://prometheus.io/download/
2.上传到需要监控的MySQL的机器上进行解压
解压安装
tar -xzvf mysqld_exporter-0.14.0.linux-amd64.tar.gz
为了后续使用方便将名称修改为:mysqld_exporter
export DATA_SOURCE_NAME='root:123456@@(127.0.0.1:3306)'
查看9104端口(mysqld_exporter默认)
修改普罗米修斯web的配置yml文件
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # 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" # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ["localhost:9090"] - job_name: "mysql114" static_configs: - targets: ["10.0.0.13:9104"]
修改后重新启动
查看web界面:
这是为什么呢?是因为13的服务器开着防火墙呢。
关闭防火墙后再看状态
再次查看web界面就正常了。
参考地址:https://www.likecs.com/show-205181945.html
标签:rules,global,普罗米修斯,scrape,job,every,监控,MySQL From: https://www.cnblogs.com/ckfuture/p/17333026.html