如何使用docker快速启动一个prometheus?

提问者:帅平 问题分类:运维
如何使用docker快速启动一个prometheus?
1 个回答
丢一地的真心、没人珍惜
丢一地的真心、没人珍惜
使用docker启动prometheus,方法如下:
1、创建配置文件
#创建conf文件夹
mkdir /home/pubserver/prometheus/conf/
#进入到conf文件夹
cd /home/pubserver/prometheus/conf/
#创建prometheus.yml文件
touch prometheus.yml
#把如下的内容保存到prometheus.yml文件中
global:
  scrape_interval: 15s
 
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
2、使用如下的命令启动
sudo docker run --name prometheus -d --privileged=true -u=root \
    -p 9090:9090 \
    -v /etc/localtime:/etc/localtime:ro \
    -v /home/pubserver/prometheus/data:/prometheus/data \
    -v /home/pubserver/prometheus/conf:/prometheus/config \
    -v /home/pubserver/prometheus/rules:/prometheus/rules \
    prom/prometheus:v2.41.0 --config.file=/prometheus/config/prometheus.yml --web.enable-lifecycle
3、访问http://xxxx:9090端口
发布于:4个月前 (01-10) IP属地:四川省
我来回答