【发布时间】:2021-06-17 13:23:24
【问题描述】:
我希望使用 docker-images / docker-for-windows 在我的开发人员机器上运行 Prometheus 和 Grafana。
我有正在开发的系统,ASP.Net 核心,在 localhost:5001 上运行,并且指标在 https://localhost:5001/metrics 上显示得很好。
Docker-compose.yml 和 prometheus.yml 列出如下。
- 如果我在 docker-compose.yml 中包含 network_mode: host,我将无法访问 我的物理机上的 Prometheus 通过 localhost:9090
- 如果我排除 network_mode 而是使用 ports: ,我可以在我的 物理机通过 localhost:9090,但检查 http://localhost:9090/targets,它显示 https://localhost:5001/metrics 已关闭。
我做错了什么?欢迎任何cmets!
docker-compose.yml:
version: '3.8'
services:
prometheus:
image: prom/prometheus
container_name: gradle_docker-prometheus
#network_mode: host
ports:
- 9090:9090
volumes:
- prometheus-storage:/var/lib/prometheus
- /c/Data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
grafana:
image: grafana/grafana
container_name: gradle_docker-grafana
ports:
- "3000:3000"
volumes:
- grafana-storage:/opt/grafana/data
depends_on:
- prometheus
volumes:
prometheus-storage: {}
grafana-storage: {}
prometheus.yml:
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'my-project'
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 10s
scheme: http
static_configs:
- targets: ['localhost:9090','cadvisor:8080','node-exporter:9100', 'nginx-exporter:9113']
- job_name: '.Net'
scrape_interval: 10s
scheme: https
static_configs:
- targets: ['localhost:5001']
【问题讨论】:
标签: docker docker-compose prometheus docker-for-windows