Локальная машина это MacBook m1. На localhost развернуто node.js приложение с эндпоинтом localhost:9650/metrics. Локально обращение по этому эндпоинту позволяет получить метрики prometheus. В докер контейнере развернут прометеус командой
docker run -p 9090:9090 -v xxx/prometheus/prometheus.yaml:/etc/prometheus/prometheus.yml prom/prometheus
файл конфигурации prometheus.yml
global:
scrape_interval: 5s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: [ 'localhost:9650' ]
После запуска вебинтерфейс прометеуса доступен по адресу localhost:9090 Но таргет localhost:9650 из контейнера не доступен.
Что пробовал использовать:
- соединять порт 9650 с портом 9651 в контейнере, указывая этот порт у таргета.
- использовать --add-host host.docker.internal:host-gateway и указывать тагрет как host.docker.internal:9650
- --net host
- brew install chipmk/tap/docker-mac-net-connect
--add-host
)