Docker prom/Prometheus 容器退出

标签 docker containers prometheus nginx-config

当我运行此命令时,它会创建 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 日志 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 >>'] 

关于Docker prom/Prometheus 容器退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52160024/

相关文章:

docker - Git 到 docker 导出

Docker ADD不会提取fi

docker - 将单个VM与Vagrant结合使用可在多个项目中托管Docker容器

design-patterns - 如果主题是一个巨大的容器,您如何有效地实现观察者模式?

go - 如何在 golang 网络服务器中使用 prometheus 监控请求成本时间

Prometheus:pod 被杀死后如何求和?

Docker 推送-net/http : TLS handshake timeout

c++ - 用于获取多个容器引用的可变参数模板

c++ - 为什么c++11标准库中没有std::clear

kubernetes - 如何区分同名 Prometheus 指标与 Kubernetes 中动态发现的微服务