1.下载Prometheus 启动, 配置文件在底部。
prometheus -config.file prometheus.yml -web.listen-address :9091
2.下载node_exporter,mysql_exporter,redis_exporter
mysqld_exporter -config.my-cnf=my.cnf
redis_exporter -web.listen-address :9122 -redis.password=rediscmit
node_exporter --web.listen-address=localhost:9100
配置里的scrape_configs
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:9091']
- job_name : '服务器'
static_configs:
- targets:
- '127.0.0.1:9100'
labels:
instance: 测试服务器
- targets:
- '172.26.117.241:9100'
labels:
instance: 主服务器
- targets:
- '172.26.117.240:9100'
labels:
instance: 开奖服务器
- targets:
- '39.100.198.66:9100'
labels:
instance: 体育服务器
- job_name : '数据库'
static_configs:
- targets:
- '127.0.0.1:9104'
labels:
instance: 测试服务器
- targets:
- '172.26.117.241:9104'
labels:
instance: 主服务器
- targets:
- '172.26.117.240:9104'
labels:
instance: 开奖服务器
- targets:
- '39.100.198.66:9104'
labels:
instance: 体育服务器
- job_name : 'Redis'
static_configs:
- targets:
- '127.0.0.1:9122'
labels:
instance: 测试服务器
- targets:
- '172.26.117.241:9122'
labels:
instance: 主服务器
- targets:
- '172.26.117.240:9122'
labels:
instance: 开奖服务器
- targets:
- '39.100.198.66:9122'
labels:
instance: 体育服务器