This exporter uses Apocas's Dockerode library.
This exporter was created because the official Docker exporter only exports engine metrics not containers', and the alternative Google's cAdvisor uses quite a lot of resources to run.
The output essentially mirrors the CLI output of docker stats
.
--port 9487 Exporter listens on this port (default = 9487)
--interval 15 Polling interval in seconds (default = 15, minimum 3)
--hostip 127.0.0.1 Docker engine IP to connect to (if using HTTP)
--hostport 2375 Docker engine port to connect to (if using HTTP)
--collectdefault Collect default Prometheus metrics as well (default = false)
If no hostip
and hostport
provided, it defaults to connect via socket to /var/run/docker.sock
.
The arguments can also be set as env variables instead. Useful if you're using it in a Docker container.
- DOCKERSTATS_PORT
- DOCKERSTATS_INTERVAL
- DOCKERSTATS_HOSTIP
- DOCKERSTATS_HOSTPORT
- DOCKERSTATS_DEFAULTMETRICS
Node.js 14 is required to run it.
git clone git@github.com:wywywywy/docker_stats_exporter.git
cd docker_stats_exporter
npm ci
npm start
docker run -d --restart=always -p 9487:9487 -v /var/run/docker.sock:/var/run/docker.sock wywywywy/docker_stats_exporter:latest
Add this to prometheus.yml
and change the IP/port if needed.
- job_name: 'docker_stats_exporter'
metrics_path: /
static_configs:
- targets:
- '127.0.0.1:9487'
If you don't see any memory metrics, try to run docker stats
to see if the memory usage ever goes above zero. If not, that means cgroup memory support is not enabled in the kernel, which is most likely the reason if you're using Raspberry Pi OS.
See this issue for instructions to have it enabled: moby/moby#18420
Because of the way docker stats
works, it always takes at least 2 seconds to output the results. Basically it takes a snapshot, then after a second it takes another snapshot to compare the results.
So there is no point pooling the Docker engine more than once every 3 or so seconds.
Also because docker stats
runs one process for each container to gather metrics, this exporter is not suitable for hosts that have a large number (hundreds) of containers.
Block IO metrics- Other useful metrics not in
docker stats
Yes, contributions are always welcome.
Fork it, clone it, submit a pull request, etc.
This is licensed under the Apache License 2.0.