Skip to content

Commit 7ba6db8

Browse files
committed
Collect hardware and OS metrics with node exporter
- Main examples: - https://github.com/oijkn/Docker-Raspberry-PI-Monitoring/blob/main/docker-compose.yml#L46-L65 - https://github.com/prometheus/node_exporter/tree/f35a592dd65d6b3488426a789b328c8ca5b2bc22?tab=readme-ov-file#docker - https://theawesomegarage.com/blog/monitor-your-raspberry-pi-with-prometheus-and-grafana - I attempted to use `network_mode: host` as in the node_exporter README example, but then I needed to add `extra_hosts: ["host.docker.internal:host-gateway"]` to the prometheus service and `- targets: ['host.docker.internal:9100']` to prometheus.yml as recommended by https://stackoverflow.com/a/66689508 but the connection was always refused - Additionally, I think this would have exposed the :9100/metrics endpoint publicly - The downside of not using `network_mode: host` is that the network metrics only include network traffic that goes through the docker container, and not the node itself. This should be fine though, since theoretically all network traffic that isn't admin-related (i.e. me) should go through the docker containers - I needed to remove rslave from `/:/host:ro,rslave` or else `dc up` failed on mac. - https://docs.docker.com/engine/storage/bind-mounts/#configure-bind-propagation - prometheus/node_exporter#2002 - prometheus-community/helm-charts#467 - prometheus/node_exporter#610 (comment)
1 parent bc6222e commit 7ba6db8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

compose.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ services:
8181
image: prometheuscommunity/postgres-exporter:v0.15.0
8282
ports:
8383
- "127.0.0.1:9187:9187"
84+
monitor-node:
85+
image: prom/node-exporter:v1.8.2
86+
command:
87+
- --path.procfs=/host/proc
88+
- --path.sysfs=/host/sys
89+
- --path.rootfs=/host
90+
ports:
91+
- "127.0.0.1:9100:9100"
92+
restart: unless-stopped
93+
volumes:
94+
- /proc:/host/proc:ro
95+
- /sys:/host/sys:ro
96+
- /:/rootfs:ro
97+
- /:/host:ro
8498
site:
8599
build:
86100
context: site

monitor/prometheus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ scrape_configs:
1111
- job_name: 'cadvisor'
1212
static_configs:
1313
- targets: ['monitor-containers:8080']
14+
- job_name: 'node-exporter'
15+
static_configs:
16+
- targets: ['monitor-node:9100']

0 commit comments

Comments
 (0)