I would like to have Prometheus and Grafana running on my developer machine using docker-images / docker-for-windows.
I have system-under-development, ASP.Net core, running on localhost:5001 and metrics are showing just fine on https://localhost:5001/metrics.
Docker-compose.yml and prometheus.yml listed below.
- If I include network_mode: host in docker-compose.yml, I can't access Prometheus on my physical machine via localhost:9090
- If I exclude network_mode and instead use ports: , I can access Prometheus on my physical machine via localhost:9090, but checking http://localhost:9090/targets, it shows https://localhost:5001/metrics as being down.
What am I doing wrong? Any comments welcome!
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']