无法通过docker加载prometheus.yml配置文件(prom/prometheus) [英] Can't load prometheus.yml config file with docker (prom/prometheus)

查看:1683
本文介绍了无法通过docker加载prometheus.yml配置文件(prom/prometheus)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下自定义conf文件向docker加载prometheus: danilo @ machine:/prometheus-data/prometheus.yml :

I am trying to load prometheus with docker using the following custom conf file: danilo@machine:/prometheus-data/prometheus.yml:


global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.

# Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: 'codelab-monitor'

# Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: 'codelab-monitor'

# A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label job=<job_name> to any timeseries scraped from this config. - job_name: 'prometheus'

# A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label job=<job_name> to any timeseries scraped from this config. - job_name: 'prometheus'

使用以下命令:

$ sudo docker run -p 9090:9090 prom/prometheus --config.file =/prometheus- data/prometheus.yml

$ sudo docker run -p 9090:9090 prom/prometheus --config.file=/prometheus- data/prometheus.yml

该文件已存在.但是,我收到以下消息:

The file already exists. However, I am getting the following message:

level = error ts = 2018-09-26T17:45:00.586704798Z caller = main.go:617 err =从\"/prometheus-data/prometheus.yml \加载配置时出错:无法加载配置(--config.file = \"/prometheus-data/prometheus.yml \"):打开/prometheus-data/prometheus.yml:没有这样的文件或目录"

level=error ts=2018-09-26T17:45:00.586704798Z caller=main.go:617 err="error loading config from \"/prometheus-data/prometheus.yml\": couldn't load configuration (--config.file=\"/prometheus-data/prometheus.yml\"): open /prometheus-data/prometheus.yml: no such file or directory"

我正在遵循本指南:

如何正确加载此文件?

推荐答案

通过该文件已存在",您是否表示该文件位于主机上的/prometheus-data/prometheus.yml?如果是这样,则需要将其绑定安装到容器中,以便Prometheus可以访问它.

By "the file already exists", do you mean that the file is on your host at /prometheus-data/prometheus.yml? If so, then you need to bind mount it into your container for it to be accessible to Prometheus.

sudo docker run -p 9090:9090 -v /prometheus-data/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

卷&在文档中绑定安装.

这篇关于无法通过docker加载prometheus.yml配置文件(prom/prometheus)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆