Hey,

meanwhile people generally know (and agree) that cAdvisor is the guy in the run to keep track of container metrics, there’s a sort of hidden feature of the docker daemon that people don’t take into account: the daemon by itself can be monitored too.

While you certainly can determine whether the daemon is running by checking the systemd metrics via cAdvisor (if you’re running the Docker daemon as a systemd service), you can’t know much more than that.

Using the native docker daemon metrics you can get much more.

Turning Docker daemon metrics on

To turn the feature on, change your daemon.json (usually at /etc/docker/daemon.json) file to allow experimental features and tell it an address and path to expose the metrics.

For instance:

{
        "expermental": true,
        "metrics-addr": "0.0.0.0:9100"
}

With that done, check out whether it’s indeed exporting the metrics:

curl localhost:9100/metrics

        # 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
        ...

Neat, all working!

Gathering Docker daemon metrics on MacOS

If you’re a Docker-for-mac user, then there’s a little difference.

First, you’ll not have the /etc/docker/daemon.json file - this is all managed by the Docker mac app, which doesn’t prevent you from tweaking the daemon configurations though.

Head over to the preferences pannel:

Location of the Docker-for-mac preferences menu

Once there, head to the Daemon tab and switch to the advanced mode.

Location of the Docker-for-mac preferences menu

With that configuration set, you’re now able to properly reach the docker-for-mac daemon metrics: curl localhost:9100 from your mac terminal.