我使用 Docker Compose(docker-compose.yml 如下所示)在同一个 Ubuntu 18.04 系统上启动了 Prometheus、Grafana 和 Nodeexporter。
问题:我无法通过 访问 Nodeexporter http://<ip.address>:9100/metrics
,而 Promethus 和 Grafana 可以分别在http://<ip.address>:9090
和访问http://<ip.address>:3000
。
nodeexporter
的 docker logs 显示它正在侦听端口 9100,但lsof
没有显示这一点。
为什么nodeexporter
无法监听 9100 端口?
的输出docker logs nodeexporter
time="2020-01-21T16:38:07Z" level=info msg="Starting node_exporter (version=0.18.1, branch=HEAD, revision=3db77732e925c08f675d7404a8c46466b2ece83e)" source="node_exporter.go:156"
time="2020-01-21T16:38:07Z" level=info msg="Build context (go=go1.12.5, user=root@b50852a1acba, date=20190604-16:41:18)" source="node_exporter.go:157"
time="2020-01-21T16:38:07Z" level=info msg="Enabled collectors:" source="node_exporter.go:97"
time="2020-01-21T16:38:07Z" level=info msg=" - arp" source="node_exporter.go:104"
...
time="2020-01-21T16:38:07Z" level=info msg=" - xfs" source="node_exporter.go:104"
time="2020-01-21T16:38:07Z" level=info msg=" - zfs" source="node_exporter.go:104"
time="2020-01-21T16:38:07Z" level=info msg="Listening on :9100" source="node_exporter.go:170"
的输出lsof -i :3000,9100,9090
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 22163 root 4u IPv6 3751831 0t0 TCP *:9090 (LISTEN)
docker-pr 22202 root 4u IPv6 3751884 0t0 TCP *:3000 (LISTEN)
的输出curl localhost:9100
curl: (7) Failed to connect to localhost port 9100: Connection refused
码头工人-compose.yml
改编自https://github.com/stefanprodan/dockprom/blob/master/docker-compose.yml
version: '2.1'
networks:
monitor-net:
driver: bridge
default:
external:
name: ${NETWORK}
services:
prometheus:
image: prom/prometheus:v2.15.2
container_name: prometheus
volumes:
- ./prometheus:/etc/prometheus
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
restart: unless-stopped
expose:
- 9090
networks:
- monitor-net
labels:
org.label-schema.group: "monitoring"
nodeexporter:
image: prom/node-exporter:v0.18.1
container_name: nodeexporter
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
restart: unless-stopped
expose:
- 9100
networks:
- monitor-net
labels:
org.label-schema.group: "monitoring"
grafana:
image: grafana/grafana:6.5.3
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
GF_SECURITY_ADMIN_USER: ${ADMIN_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${ADMIN_PASSWORD:-admin}
GF_USERS_ALLOW_SIGN_UP: "false"
VIRTUAL_HOST: ${DOMAINS}
LETSENCRYPT_HOST: ${DOMAINS}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
restart: unless-stopped
expose:
- 3000
networks:
- monitor-net
labels:
org.label-schema.group: "monitoring"
...