无法使用docker(prom / prometheus)加载prometheus.yml配置文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用docker(prom / prometheus)加载prometheus.yml配置文件相关的知识,希望对你有一定的参考价值。
我正在尝试使用以下自定义配置文件加载带有docker的prometheus:danilo @ machine:/prometheus-data/prometheus.yml:
global: scrape_interval: 15s # By default, scrape targets every 15 seconds.#在与#external systems(federation,remote storage,Alertmanager)通信时,将这些标签附加到任何时间序列或警报。 external_labels:monitor:'codelab-monitor'
#刮擦配置只包含一个端点:#这是普罗米修斯本身。 scrape_configs:#作业名称被添加为标签
job=<job_name>
到从此配置中删除的任何时间序列。 - job_name:'prometheus'# Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 5s static_configs: - targets: ['localhost:9090'] - targets: ['localhost:8083', 'localhost:8080'] labels: my_app group: 'my_app_group'
使用以下命令:
$ sudo docker run -p 9090:9090 prom / prometheus --config.file = / prometheus- data / prometheus.yml
该文件已存在。但是,我收到以下消息:
level = error ts = 2018-09-26T17:45:00.586704798Z caller = main.go:617 err =“错误加载配置来自”/ prometheus-data / prometheus.yml “:无法加载配置( - config.file = “/ prometheus-data / prometheus.yml ”):open /prometheus-data/prometheus.yml:没有这样的文件或目录“
我正在按照本指南操作:
如何正确加载此文件?
通过“文件已存在”,您的意思是该文件位于/prometheus-data/prometheus.yml
的主机上吗?如果是这样,那么您需要将它装入容器中,以便Prometheus可以访问它。
sudo docker run -p 9090:9090 -v /prometheus-data/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
它在文档中的Volumes & bind-mount中有所涉及。
以上是关于无法使用docker(prom / prometheus)加载prometheus.yml配置文件的主要内容,如果未能解决你的问题,请参考以下文章
无法使用docker(prom / prometheus)加载prometheus.yml配置文件
14Docker监控方案(Prometheus+cAdvisor+Grafana)
docker-compose 打开存储失败:运行时权限被拒绝错误