系统:Centos7
docker pull prom/prometheus
ifconfig | grep -A 1 docker0
mkdir -p /home/prometheus
vi /home/prometheus/prometheus.yml
配置文件写入一下内容(targets对应服务器所在的地址)
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['172.17.0.1:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['10.100.1.15:9100']
- job_name: mysql
static_configs:
- targets: ['172.17.0.1:9104']
创建容器,设置自启动
docker run -itd --name prometheus -p 9090:9090 --restart=always -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /etc/localtime:/etc/localtime:ro prom/prometheus
启动后访问 http://服务器地址:9090