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







































