docker-compose.yml
version: "3"services:prometheus:container_name: prometheusimage: prom/prometheus:v2.23.0ports:- 9090:9090volumes:- ./prometheus.yml:/etc/prometheus/prometheus.yml- ./data:/prometheus
新建 ./prometheus.yml 文件,该文件是 prometheus 的配置文件,默认配置如下:
# my global configglobal: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 configurationalerting: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']
如果要手机新的系统的监控信息,可以在 scrape_configs 下新增一个 job ,以 mysql 为例:
- job_name: 'mysql8'static_configs:- targets: ['192.168.0.103:9104']
如果
mysqld-exporter已经把端口暴露出来的话,targets可以填宿主机器 ip,或者与mysqld-exporter在同个网络下的话,可以填mysql-exporter-network:9104
