Bird
Raised Fist0
Dockerdevops~5 mins

Prometheus for Docker monitoring - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is Prometheus used for in Docker monitoring?
Prometheus collects and stores metrics from Docker containers to help monitor their performance and health.
Click to reveal answer
beginner
How does Prometheus get metrics from Docker containers?
Prometheus scrapes metrics from exporters running inside or alongside Docker containers, such as cAdvisor or node_exporter.
Click to reveal answer
intermediate
What is cAdvisor and why is it important for Docker monitoring with Prometheus?
cAdvisor is a tool that collects resource usage and performance data from Docker containers and exposes it in a format Prometheus can scrape.
Click to reveal answer
intermediate
Which file do you configure to tell Prometheus where to find Docker metrics?
You configure the 'prometheus.yml' file to add scrape jobs that point to Docker metrics endpoints like cAdvisor.
Click to reveal answer
beginner
What command starts Prometheus with a custom configuration file for Docker monitoring?
docker run -d -p 9090:9090 -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
Click to reveal answer
What port does Prometheus use by default to serve its web UI?
A8080
B3000
C9090
D9100
Which tool exposes Docker container metrics for Prometheus to scrape?
AcAdvisor
BGrafana
CKubernetes
DDocker Compose
Where do you specify the targets Prometheus should scrape?
Aconfig.json
BDockerfile
Cdocker-compose.yml
Dprometheus.yml
What is the main purpose of Prometheus in Docker monitoring?
ABuild Docker images
BCollect and store container metrics
CDeploy containers
DManage container networking
Which command runs Prometheus in a Docker container exposing port 9090?
Adocker run -d -p 9090:9090 prom/prometheus
Bdocker run -d -p 8080:8080 prom/prometheus
Cdocker start prometheus
Ddocker exec -it prometheus bash
Explain how Prometheus monitors Docker containers and what components are involved.
Think about how Prometheus gets data from containers.
You got /4 concepts.
    Describe the steps to set up Prometheus to monitor Docker containers on your local machine.
    Focus on running exporters and configuring Prometheus.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the main role of Prometheus when monitoring Docker containers?
      easy
      A. To run Docker containers automatically
      B. To collect and store metrics from Docker containers
      C. To build Docker images from Dockerfiles
      D. To replace Docker Engine for container management

      Solution

      1. Step 1: Understand Prometheus purpose

        Prometheus is designed to collect and store metrics data from various sources, including Docker containers.
      2. Step 2: Differentiate from other Docker tools

        Prometheus does not run containers, build images, or replace Docker Engine; it focuses on monitoring.
      3. Final Answer:

        To collect and store metrics from Docker containers -> Option B
      4. Quick Check:

        Prometheus = Metrics collection [OK]
      Hint: Remember: Prometheus collects data, not runs containers [OK]
      Common Mistakes:
      • Confusing Prometheus with Docker Engine
      • Thinking Prometheus builds images
      • Assuming Prometheus runs containers
      2. Which Docker command correctly starts cAdvisor to provide metrics for Prometheus?
      easy
      A. docker run --name cadvisor -p 8080:8080 gcr.io/cadvisor/cadvisor:latest
      B. docker run --name cadvisor -p 8080:8080 google/cadvisor:latest
      C. docker run --name cadvisor -p 9090:9090 prom/cadvisor:latest
      D. docker run --name cadvisor -p 9090:8080 google/cadvisor:stable

      Solution

      1. Step 1: Identify correct cAdvisor image and port

        The official cAdvisor image is hosted at gcr.io/cadvisor/cadvisor:latest and listens on port 8080.
      2. Step 2: Check port mapping and image name

        docker run --name cadvisor -p 8080:8080 gcr.io/cadvisor/cadvisor:latest correctly maps port 8080:8080 and uses the official image name.
      3. Final Answer:

        docker run --name cadvisor -p 8080:8080 gcr.io/cadvisor/cadvisor:latest -> Option A
      4. Quick Check:

        cAdvisor image and port = docker run --name cadvisor -p 8080:8080 gcr.io/cadvisor/cadvisor:latest [OK]
      Hint: Official cAdvisor image is gcr.io/cadvisor/cadvisor:latest [OK]
      Common Mistakes:
      • Using wrong image repository
      • Mapping wrong ports
      • Using outdated or incorrect image tags
      3. Given this Prometheus scrape config snippet for Docker monitoring:
      scrape_configs:
        - job_name: 'cadvisor'
          static_configs:
            - targets: ['localhost:8080']

      What will Prometheus do when started with this config?
      medium
      A. Fail to start due to invalid config syntax
      B. Scrape metrics from Docker Engine API on port 8080
      C. Scrape metrics from all Docker containers directly
      D. Scrape metrics from cAdvisor running on localhost port 8080

      Solution

      1. Step 1: Analyze scrape_configs job_name and targets

        The job 'cadvisor' targets 'localhost:8080', which is the default cAdvisor port.
      2. Step 2: Understand Prometheus scraping behavior

        Prometheus will scrape metrics from the specified target, not Docker Engine API or all containers directly.
      3. Final Answer:

        Scrape metrics from cAdvisor running on localhost port 8080 -> Option D
      4. Quick Check:

        Prometheus scrapes targets listed = Scrape metrics from cAdvisor running on localhost port 8080 [OK]
      Hint: Targets in scrape_configs define where Prometheus scrapes [OK]
      Common Mistakes:
      • Confusing cAdvisor with Docker Engine API
      • Assuming Prometheus scrapes containers directly
      • Thinking config syntax is invalid
      4. You started Prometheus and cAdvisor with Docker Compose, but Prometheus shows no metrics from cAdvisor. What is the likely cause?
      medium
      A. Prometheus cannot scrape metrics from port 9090
      B. Prometheus config has wrong job_name
      C. cAdvisor container is not exposing port 8080 to Prometheus
      D. Docker Compose file is missing image tags

      Solution

      1. Step 1: Check port exposure between cAdvisor and Prometheus

        If cAdvisor does not expose port 8080 or network is misconfigured, Prometheus cannot scrape metrics.
      2. Step 2: Verify other options

        Wrong job_name or missing image tags usually cause errors but not silent no metrics; port 9090 is Prometheus default, not cAdvisor.
      3. Final Answer:

        cAdvisor container is not exposing port 8080 to Prometheus -> Option C
      4. Quick Check:

        Port exposure needed for scraping = cAdvisor container is not exposing port 8080 to Prometheus [OK]
      Hint: Check port mapping between containers first [OK]
      Common Mistakes:
      • Ignoring port exposure issues
      • Assuming job_name mismatch causes no metrics
      • Confusing Prometheus and cAdvisor ports
      5. You want to monitor multiple Docker hosts with Prometheus and cAdvisor. Which setup is best?
      hard
      A. Run cAdvisor on each host exposing metrics, configure Prometheus to scrape all hosts
      B. Run one cAdvisor container on a central host to monitor all hosts
      C. Run Prometheus on each host and aggregate metrics manually
      D. Use Docker Compose to run a single cAdvisor and Prometheus on one host only

      Solution

      1. Step 1: Understand cAdvisor scope

        cAdvisor monitors containers on the host it runs on; to monitor multiple hosts, run cAdvisor on each host.
      2. Step 2: Configure Prometheus for multi-host scraping

        Prometheus can scrape metrics from multiple cAdvisor instances by listing all hosts in its config.
      3. Step 3: Evaluate other options

        Central cAdvisor cannot monitor other hosts; running Prometheus on each host complicates aggregation; single host setup misses other hosts.
      4. Final Answer:

        Run cAdvisor on each host exposing metrics, configure Prometheus to scrape all hosts -> Option A
      5. Quick Check:

        One cAdvisor per host + Prometheus scrape all = Run cAdvisor on each host exposing metrics, configure Prometheus to scrape all hosts [OK]
      Hint: One cAdvisor per host, Prometheus scrapes all [OK]
      Common Mistakes:
      • Thinking one cAdvisor can monitor all hosts
      • Running multiple Prometheus instances unnecessarily
      • Ignoring multi-host scraping config
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard