1、下载进行
docker pull prom/prometheus
2、维护配置信息
mkdir /opt/prometheus
cd /opt/prometheus/
vim prometheus.yml
- 内容如下
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus
- [再加个data文件夹用于挂载prometheus的数据]
mkdir /opt/prometheus/data
- 将挂载目录权限设置为777 [防止run时候提示data没有权限创建文件目录啥的]
chmod 777 -R /opt/prometheus
3、启动Docker
docker run -d \
-p 9090:9090 \
-v /opt/prometheus/prometheus1.yml:/etc/prometheus/prometheus.yml \
-v /opt/prometheus/data:/prometheus \
prom/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.retention.time=100d
- storage.tsdb.retention.time=100d 【保留100天数据】
4、检查是否启动
docker安装prometheus建议参考 prometheus-practice