Docker prom / Prometheus容器退出

问题描述 投票:0回答:1

当我运行此命令时,它会创建docker容器但显示退出状态,我无法启动它

我的目标是能够用自定义prometheus.yml替换prometheus.yml文件来监视运行在http://localhost:70/nginx_status的nginx

   docker run -it -d --name prometheus3 -p 9090:9090 -v 
    /opt/docker/prometheus:/etc/prometheus prom/prometheus - 
    config.file=/etc/prometheus/prometheus.yml

这是我的prometheus.yml文件

     scrape_configs: 
     - job_name: 'prometheus' 

     scrape_interval: 5s 
     scrape_timeout: 5s 

     static_configs: 
       - targets: ['localhost: 9090'] 

       - job_name: 'node' 
     static_configs: 
     - targets: ['localhost: 70/nginx_status'] 
docker containers prometheus nginx-config
1个回答
0
投票

您应该能够通过运行以下命令查看已停止容器的日志:

docker logs prometheus3

无论如何,您的配置存在(至少)两个问题:

  1. prometheus.yml文件无效,因此prometheus进程立即退出。 scrape_intervalscrape_timeout需要在global部分,并且缩进是关闭的。有关格式正确的yml文件的示例,请参见下文。 2.)你不能只抓取/nginx_status端点,但需要使用nginx导出器为你提取指标。然后,Prometheus服务器将刮取nginx_exporter以检索指标。你可以找到一个出口商列表here并选择一个适合你的。 一旦您运行导出器,您需要将Prometheus指向导出器的地址,以便可以将其删除。

工作prometheus.yml:

global:
  scrape_interval: 5s 
  scrape_timeout: 5s 

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'node' 
    static_configs: 
    - targets: ['<< host name and port of nginx exporter >>'] 
© www.soinside.com 2019 - 2024. All rights reserved.