Collecting and scraping metrics
To collect and scrape metrics from containers running on a system with Docker Desktop installed, you can use Prometheus and Container Advisor (cAdvisor). Prometheus is a powerful open source monitoring and alerting toolkit, while cAdvisor provides container users with an understanding of the resource usage and performance characteristics of their running containers.
In this section, we’ll provide a step-by-step guide to setting up Prometheus and cAdvisor to collect and scrape metrics from containers running on Docker Desktop.
Step 1 – running cAdvisor in a Docker container
cAdvisor is a Google-developed tool that collects, processes, and exports container metrics. Let’s take a look:
- In the chapter folder,
ch12
, create a new subfolder calledmetrics
:mkdir metrics
- In this folder, create a file called
docker-compose.yml
and add the following snippet to it:version: '3.8'services: cadvisor: ...