第一步拉取prometheus docker镜像
docker pull prom/prometheus
第二步编写docker-compose.yml 文件
prometheus: image: prom/prometheus container_name: prometheus restart: always ports: - '9090:9090' volumes: - ./prometheus/data:/prometheus - ./prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml command: "--config.file=/etc/prometheus/prometheus.yml"
第三步 编写对应的prometheus.yml文件 放入对应的文件夹
global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['192.168.0.110:9090'] - job_name: 'pushgateway' static_configs: - targets: ['pushgateway:9091']
第四步运行 prometheus
docker-compose up -d prometheus
注意:要在docker-compose.yml目录下运行 需要新建一个prometheus文件夹 并且给读写权限,否则会报错
第五步 检查是否运行成功
访问 192.168.0.110:9090 查看是否有界面
第六步 拉取pushgateway镜像
docker pull prom/pushgateway
第七步 编写docker-compose.yml 文件
pushgateway: image: prom/pushgateway container_name: pushgateway restart: always ports: - '9091:9091'
第八步运行 pushgateway
docker-compose up -d pushgateway
注意:要在docker-compose.yml目录下运行 需要新建一个prometheus文件夹 并且给读写权限,否则会报错
第五步 检查是否运行成功
访问 192.168.0.110:9091 查看是否有界面