liveBook · Manning

Performance

As explained in Learn Docker in a Month of Lunches, Second Edition

A metric is a quantitative measurement of a system, application, process, or outcome.

A container can be running while its application is struggling. Performance metrics provide measurements of what the application and its runtime are doing, so monitoring can reveal heavy resource use and help pinpoint problems. Prometheus collects metrics exposed by containers; Grafana can display them in dashboards. section 9.0 section 9.2

Start with two sources of measurements:

  • Enable Docker Engine metrics in its configuration, then open http://localhost:9323/metrics to check the output. The setting publishes metrics on port 9323; the Engine’s metrics feature is considered experimental, so its details could change. section 9.1
  • Add a Prometheus client library to each application component to collect runtime measurements and expose an HTTP endpoint. For example, Go metrics include active goroutines, while Java metrics include JVM memory use. section 9.2
  • Add custom metrics when runtime measurements do not answer an application-specific question. A Node.js component can increment a counter for total access-log requests and set a gauge for the current number of unique client IP addresses. section 9.2
"metrics-addr" : "0.0.0.0:9323"

Set `metrics-addr` to `0.0.0.0:9323` to publish Docker Engine metrics. Edit `daemon.json` on Windows Server or Linux, or use Docker Desktop’s Docker Engine settings. section 9.1

Check an instrumented application

From `./ch09/exercises`, start the image-gallery project with `docker-compose up -d`, use the application at `http://localhost:8010`, then open `http://localhost:8010/metrics`. That endpoint exposes Go runtime measurements without custom metric code. The Java REST API exposes similar measurements at `http://localhost:8011/actuator/prometheus`. The raw endpoints are dense text; a dashboard makes selected measurements easier to follow. section 9.2 section 9.0

Use the same Prometheus metric format across application containers and the Docker Engine. This gives a monitoring stack measurements from both the application and the platform, without relying on a fixed list of container IP addresses. section 9.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Shows how to enable Engine metrics, inspect application endpoints, and declare custom metrics; leaves collection mechanics to Prometheus clients.
Examples
Uses Docker Engine output, Go and Java runtime endpoints, and Node.js access-log counter and client-IP gauge declarations.
What it assumes
Assumes a working Docker environment and basic command-line use; introduces application instrumentation through client libraries.
What you can do after
Apply it via Prometheus client libraries to expose metrics, inspect HTTP endpoints, and visualize collected data with Grafana.
How it connects
Connects performance metrics to observability, Docker Engine monitoring, Prometheus collection, Grafana dashboards, and application runtime metrics.

Also explained in

Compare how 40 books explain performance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.