docker工人 – 普罗米修斯集装箱马上死亡

我有一个使用端口映射4000:8080的pipe理程序,我必须将它与一个带有prometheus的容器链接起来。

我的prometheus.yml是:

scrape_configs: # Scrape Prometheus itself every 2 seconds. - job_name: 'prometheus' scrape_interval: 2s target_groups: - targets: ['localhost:9090', 'cadvisor:8080'] 

这个文件有path/home/test/prometheus.yml。 用普罗米修斯来运行容器,我这样做:

 docker run -d -p 42047:9090 --name=prometheus -v /home/test/prometheus.yml:/etc/prometheus/prometheus.yml --link cadvisor:cadvisor prom/prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 

容器被创build,但它立即死亡。 你能告诉我问题在哪里吗?

消息形成docker events&

 2016-11-21T11:43:04.922819454+01:00 container start 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (image=prom/prometheus, name=prometheus) 2016-11-21T11:43:05.152141981+01:00 container die 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (exitCode=1, image=prom/prometheus, name=prometheus) 

我认为target_groups在最新版本的prometheus中已经被target_groups弃用了。 你可以试试static_configs或者file_sd_config

scrape_config
static_config
file_sd_config

 scrape_configs: - job_name: node_exporter static_configs: - targets: - "stg-elk-app-01:9100" - "stg-app-02:9100" 

缩进不正确,请尝试:

 scrape_configs: # Scrape Prometheus itself every 2 seconds. - job_name: 'prometheus' scrape_interval: 2s target_groups: - targets: ['localhost:9090', 'cadvisor:8080'] 

configuration格式已更改。 目标在最新版本的static_config下。

 scrape_configs: # Scrape Prometheus itself every 2 seconds. - job_name: 'prometheus' scrape_interval: 2s static_configs: - targets: ['localhost:9090', 'cadvisor:8080'] 

普罗米修斯文件的进一步帮助

容器的名字是prometheus

通常,当一个容器在启动后立即存在时,我build议在-log.level=debug之后添加-log.level=debug

docker run -d -p 42047:9090 --name=prometheus -v /home/test/prometheus.yml:/etc/prometheus/prometheus.yml --link cadvisor:cadvisor prom/prometheus -config.file=/etc/prometheus/prometheus.yml -log.level=debug -storage.local.path=/prometheus -storage.local.memory-chunks=10000

接下来,查看容器的日志:

docker logs prometheus

任何与configuration有关的问题将在那里。

正如你在之前的评论中所说:

from logs: time="2016-11-21T11:21:40Z" level=error msg="Error loading config: couldn't load configuration (-config.file=/etc/prometheus/prometheus.yml): unknown fields in scrape_config: target_groups" source="main.go:149"

这显然意味着“target_groups”字段导致了问题。 这是因为新版本的Prometheus(v1.5以上版本)已经放弃了“target_groups”字段的使用,只是提供了目标。 即使在6个月前我也遇到过这个问题。 请用新版本尝试。 docker pull prom/prometheus可能会让你的老。

希望这可以帮助…!!!