Docker integration with Prometheus is experimental and not enabled in the dockerd server by default.
You need to configure the dockerd server to enabled the experimental features and expose the metrics address.
The configuration can be done using the "
experimental" and "
metrics-addr" options.
The options "
--experimental" and "
--metrics-addr" can be set on the command line (systemd) when starting the dockerd server (
/lib/systemd/system/docker.service).
They can also be put into the "
daemon.json" file.
The "
daemon.json" file can be located in: "
/etc/docker/daemon.json".
Note that it might not be created by default when you install Docker.
$ vi /etc/docker/daemon.json
daemon.json:
{
"metrics-addr": "0.0.0.0:9323",
"experimental": true
}
Restart Docker:
$ sudo service docker restart
Prometheus will connect to the port "
9323" to get metrics (a listener will be listening on all addresses on port 9323).
To validate the endpoint:
$ curl -s http://localhost:9323/metrics | head -5
# HELP builder_builds_failed_total Number of failed image builds
# TYPE builder_builds_failed_total counter
builder_builds_failed_total{reason="build_canceled"} 0
builder_builds_failed_total{reason="build_target_not_reachable_error"} 0
builder_builds_failed_total{reason="command_not_supported_error"} 0