I am figuring out Network issues between Prometheus and python application within Docker. How can I make Prometheus able to scrape metrics generated by the python application within docker, and shows it on the Prometheus end.
Docker-compose.yml
version: '3'
services:
prometheus:
image: prom/prometheus:v2.0.0
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
links:
- web
web:
image: python:3.5-alpine
build: ./test
ports:
- "5000:8002"
Dockerfile:
FROM python:3.5-alpine
ADD app1.py /
RUN pip install prometheus_client
CMD ["python", "./app1.py"]
EXPOSE 8002
prometheus.yml
# my global config
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['docker.for.mac.host.internal:9090']
- job_name: 'python_app'
metrics_path: /
static_configs:
- targets: ['docker.for.mac.host.internal:8002']
So far, I can see Prometheus is running well, and its targets' status shows UP on 'docker.for.mac.host.internal:9090' and 'docker.for.mac.host.internal:8002'
And the python application is running as well, I can see the output metrics on the port
So everything should work by now, Prometheus can scrape metrics over the specified port. However there is no such metrics there.