Feedback

Chat Icon

Observability with Prometheus and Grafana

A Complete Hands-On Guide to Operational Clarity in Cloud-Native Systems

Prometheus and Docker
75%

Docker Metrics: Enabling and Configuring

We are going to run Docker and Prometheus on separate servers. We are going to use server1 to run Docker and monitoring to run Prometheus.

First of all, if Docker is not already installed, you can install it with the following command on server1:

curl -fsSL https://get.docker.com | VERSION=27.0 sh

Then, on the same server (server1), you need to enable Docker metrics:

# Replace  with the actual private IP address of server1
export server1=
export DOCKER_METRICS_ADDR=$server1:9323

Note that the monitoring server should have access to the private IP address and port specified in DOCKER_METRICS_ADDR. If not, open port 9323 in the firewall of server1.

You can also use 0.0.0.0 if you want to expose to all interfaces. However, this could be against security best practices. Create the daemon configuration file and enable the metrics (always on server1):

mkdir -p /etc/docker && cat < /etc/docker/daemon.json
{
  "metrics-addr" : "${DOCKER_METRICS_ADDR}",
  "experimental" : true
}
EOF

Restart the Docker daemon:

systemctl restart docker

Now, you can check if the metrics are being exported by running the following command:

curl http://${DOCKER_METRICS_ADDR}/metrics

There are a variety of metrics that are being exported by Docker. Some of the most common metrics are described below:

Metric NameTypeDescription
engine_daemon_container_actions_seconds_bucketHistogramTracks the number of seconds it takes to process each container action (create, start, stop, etc).
engine_daemon_container_states_containersGaugeRepresents the number of containers in various states (paused, running, stopped).
engine_daemon_engine_cpus_cpusGaugeShows the number of CPUs that the host system of the engine has.
engine_daemon_engine_infoGauge

Observability with Prometheus and Grafana

A Complete Hands-On Guide to Operational Clarity in Cloud-Native Systems

Enroll now to unlock all content and receive all future updates for free.