本文主要是介绍docker-compose安装prometheus,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.docker-compose.yml配置如下
version: '3.9'networks:monitor:driver: bridgeservices:prometheus:image: prom/prometheus:v2.28.1container_name: prometheus_gpehostname: prometheusrestart: alwaysvolumes:- /data/gpe/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml- /data/gpe/prometheus/data:/prometheuscommand:- '--config.file=/etc/prometheus/prometheus.yml'- '--storage.tsdb.path=/prometheus'ports:- "9090:9090"networks:- monitoralertmanager:image: prom/alertmanager:v0.22.2container_name: alertmanager_gpehostname: alertmanagerrestart: alwaysvolumes:- /data/gpe/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.ymlports:- "9093:9093"networks:- monitorgrafana:image: grafana/grafana:8.0.6container_name: grafana_gpehostname: grafanarestart: alwaysvolumes:- /data/gpe/grafana/data:/var/lib/grafanaports:- "3001:3000"networks:- monitor
2.我这里挂载了prometheus.yml和alertmanager.yml,这两个文件直接docker启动prometheus和alertmanager然后使用容器复制命令复制出来
docker cp 容器id:/etc/prometheus/prometheus.yml /data/gpe/alertmanager
3.启动如过报权限不足,则对prometheus和grafana的data目录加777权限
chmod 777 /data/gpe/grafana/data
4.docker-compose up -d 进行启动
这篇关于docker-compose安装prometheus的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!