Lightweight Docker Compose project and container metrics for Prometheus and Home Assistant.
2.8K
This project evolved into
rcooler/ugos-bridge (UgosBridge), a metrics bridge for UGREEN NAS hosts and Docker Compose stacks that adds host, storage, network, GPU, VM and hardware health telemetry to the Docker metrics. New installations should usercooler/ugos-bridge. Its configuration variables and metric names differ from this image, so treat it as a new installation.
The guide below describes the last docker_exporter image, 1.0.0.
docker_exporter is a lightweight Docker metrics exporter for Docker Compose style projects. It collects a small set of project and container metrics from the Docker Engine API and exposes them to Prometheus and, optionally, to Home Assistant through MQTT Discovery, without the overhead of cadvisor.
Full history: commits on GitHub. Development continues in UgosBridge: changelog.
docker run -d \
--name docker-exporter \
-p 9877:9877 \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
rcooler/docker_exporter:latest
services:
docker-exporter:
image: rcooler/docker_exporter:latest
restart: unless-stopped
ports:
- "9877:9877"
environment:
DOCKER_HOST: "unix:///var/run/docker.sock"
DOCKER_EXPORTER_MQTT_ENABLED: "true"
DOCKER_EXPORTER_MQTT_BROKER: "tcp://host.docker.internal:1883"
DOCKER_EXPORTER_MQTT_USER: "ha"
DOCKER_EXPORTER_MQTT_PASS: "change_me"
DOCKER_EXPORTER_MQTT_CLIENT_ID: "docker_exporter"
DOCKER_EXPORTER_MQTT_TOPIC_PREFIX: "docker_exporter"
DOCKER_EXPORTER_MQTT_DISCOVERY_PREFIX: "homeassistant"
DOCKER_EXPORTER_MQTT_INTERVAL: "60"
DOCKER_EXPORTER_MQTT_RETAIN: "true"
DOCKER_EXPORTER_MQTT_EXPIRE_AFTER: "360"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
Full example file: docker-compose.example.yml
DOCKER_EXPORTER_MQTT_INTERVAL and DOCKER_EXPORTER_MQTT_EXPIRE_AFTER accept either plain seconds like 60 and 360, or Go duration strings like 60s and 6m. Leave the MQTT variables out to run with Prometheus only.
- job_name: 'docker-exporter'
static_configs:
- targets: ['docker-exporter:9877']
docker_exporter_container_cpu_usage_percent, docker_exporter_container_memory_usage_bytes, docker_exporter_container_memory_limit_bytesdocker_exporter_container_running, docker_exporter_container_stats_collected, docker_exporter_container_stats_errorsdocker_exporter_project_cpu_usage_percent, docker_exporter_project_memory_usage_bytesdocker_exporter_project_total_containers, docker_exporter_project_running_containersdocker_exporter_up, docker_exporter_last_collection_timestamp_seconds| Variable | Purpose |
|---|---|
LISTEN_ADDRESS | HTTP listen address. (default: :9877) |
METRICS_PATH | Path that serves the metrics. (default: /metrics) |
SCRAPE_INTERVAL | Delay between collection cycles. (default: 15s) |
DOCKER_HOST | Docker Engine API endpoint. (default: unix:///var/run/docker.sock) |
DOCKER_TIMEOUT | Timeout for Docker API requests. (default: 5s) |
DOCKER_PROJECT_LABEL | Label that names the project. (default: com.docker.compose.project) |
STANDALONE_PROJECT_NAME | Project name for containers without that label. (default: standalone) |
CONTAINER_CONCURRENCY | Number of containers queried in parallel. (default: 4) |
com.docker.compose.project. Containers without that label are grouped under standalone.unix://, tcp://, http://, https://. npipe:// is not implemented.MIT licensed. Independent open-source project, not affiliated with, endorsed by, or sponsored by Docker, Prometheus, or Home Assistant. Product names are trademarks of their respective owners and are used only to describe compatibility and integration.
Content type
Image
Digest
sha256:3893d1d00…
Size
5.7 MB
Last updated
7 months ago
docker pull rcooler/docker_exporter