当我运行这个命令时,它创建了docker容器,但是显示在退出状态,并且我无法启动它。
我的目标是能够将prometheus.yml文件替换为自定义的prometheus.yml,以监视在状态上运行的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'] 发布于 2018-09-05 02:50:35
通过运行以下命令,您应该能够看到已停止的容器的日志:
docker logs prometheus3
无论如何,您的配置(至少)有两个问题:
scrape_interval和scrape_timeout需要在global部分,缩进是关闭的。有关正确格式化的yml文件的示例,请参阅下面。
2.)您不能只是刮掉/nginx_status端点,而是需要使用nginx导出程序来为您提取度量。然后Prometheus服务器将刮掉nginx_exporter以检索度量。你可以找到一份出口商名单,这里,并挑选一个适合你。
一旦您让出口商运行,您需要指向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 >>'] https://stackoverflow.com/questions/52160024
复制相似问题