![](/img/trans.png)
[英]How to connect Dockerized ASP.NET Core app ->Dockerized PostgreSQL?
[英]How can I monitor a ASP.Net Core app with dockerized Prometheus (and Grafana)?
我希望使用 docker-images / docker-for-windows 在我的开发人员机器上运行 Prometheus 和 Grafana。
我有正在开发的系统,ASP.Net 核心,在 localhost:5001 上运行,指标在 https://localhost:5001/metrics 上显示得很好。
下面列出了 Docker-compose.yml 和 prometheus.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: {}
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']
不要在 Windows 上使用主机网络模式,它仅在 Linux 上支持。 您需要更改目标地址:
- job_name: '.Net'
scrape_interval: 10s
scheme: https # You may have to change this to 'http'
# or you'd have to create a certificate
# with `host.docker.internal`
static_configs:
- targets: ['host.docker.internal:5001']
host.docker.internal
是连接到 Docker 主机的特殊地址,因为容器内的localhost
就是容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.