You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Usage
Arguments
--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.
Environment Variables
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
Installation
From Source
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
With Docker
docker run -d --restart=always -p 9487:9487 -v /var/run/docker.sock:/var/run/docker.sock wywywywy/docker_stats_exporter:latest
Prometheus Config
Add this to prometheus.yml and change the IP/port if needed.
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
Notes on Performance
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.
TODO
Block IO metrics
Other useful metrics not in docker stats
Contributing
Yes, contributions are always welcome.
Fork it, clone it, submit a pull request, etc.