I am running on prometheus in a container and FastAPI endpoints are running on my linux machine. I am not able to access the metrics of the APIs using prometheus.
This the entry in my prometheus.yml file:
- job_name: ‘fastapi’
static_configs:
- targets: [“host.docker.internal:8000”]
I tried using my device ip, that also didn’t work.
This is my docker-compose entry for prometheus:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
ports:
- “9090:9090”
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml # Custom config file
- prometheus_data:/prometheus # Persistent storage
extra_hosts:
- host.docker.internal:host-gateway
command:
- “–config.file=/etc/prometheus/prometheus.yml”
- “–storage.tsdb.path=/prometheus”
- “–web.enable-lifecycle”