当我运行此命令时,它会创建 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 logs prometheus3
无论如何,您的配置存在(至少)两个问题:
prometheus.yml 文件无效,因此 prometheus 进程立即退出。
在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 >>']
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句