Difficulty: beginner
Estimated Time: 10-15 minutes

With Docker 1.13, they introduced an experimental feature that allows the Docker Engine metrics to be exported using the Prometheus syntax.

Prometheus is an open source monitoring system and time series database. It's defined to collect metrics from multiple sources, such as the Operating System, MySQL or ElasticSearch, across multiple servers within your clusters. These metrics can then be graphed and displayed on a dashboard using Prometheus itself or tooling such as Grafana.

The Docker Engine metrics will include a number of containers started, stopped, created and deleted. This allows users to collect and visualise a Docker hosts activity.

Don’t stop now! The next scenario will take about 20 minutes to complete. You can pause and come back at any time.

Graphing Docker 1.13 metrics with Prometheus

Step 1 of 5

Step 1 - Enable Metrics

The first task is to enable the new experimental flag that will enable the metrics feature and define the metrics address to listen on localhost:4444.

The command below will update the systemd configuration used to start Docker to set the flags when the daemon starts and then restarts Docker.

sed -i 's/dockerd/dockerd --experimental --metrics-addr localhost:9323/g' /etc/systemd/system/docker.service systemctl daemon-reload systemctl restart docker

The metrics endpoint will be accessible once Docker has begun. You can see the raw metrics using curl localhost:9323/metrics

These metrics are outputted in the Prometheus format and designed to be scraped by a Prometheus server which will launch in the next steps.

prometheus.yml