liveBook · Manning

Scraping

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

Scraping is the periodic retrieval of monitoring data from an exposed endpoint.

Scraping is Prometheus’s pull-based process for periodically fetching monitoring data from exposed application endpoints instead of receiving pushed data. section 9.3

Configure scraping by specifying:

  • A global interval, such as 10 seconds. section 9.3
  • A job name, metrics URL path, and target list for each component. section 9.3
  • Static targets for single containers or DNS service discovery for services with multiple containers. section 9.3
Listing 9.2 Configuring Prometheus to scrape application metrics
global:
  scrape_interval: 10s

scrape_configs:
  - job_name: "image-gallery"
    metrics_path: /metrics
    static_configs:
      - targets: ["image-gallery"]

  - job_name: "iotd-api"
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: ["iotd"]

  - job_name: "access-log"
    metrics_path: /metrics
    dns_sd_configs:
      - names:
          - accesslog
        type: A
        port: 80

Use the configuration listing to compare static targets with DNS-based discovery and see metrics paths in context. section 9.3

Scaling a scraped service

DNS discovery can poll all three access-log containers on the same schedule. A single-container target behaves differently: when DNS returns several addresses, Prometheus uses the first address, so scaling that component produces unexpected behavior. section 9.3

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

How deep it goes
Explains pull behavior, intervals, endpoints, target discovery, and scaling caveats without detailing Prometheus internals.
Examples
Uses image-gallery, iotd-api, and access-log jobs with static targets, DNS discovery, and a ten-second interval.
What it assumes
Assumes containerized services expose metrics endpoints and uses Docker service names for target resolution.
What you can do after
Operate/configure Prometheus scraping for single containers or scaled services using endpoint paths and target discovery.
How it connects
Connects Prometheus, metrics endpoints, Docker DNS, DNS service discovery, Docker Compose, and load balancing.

Also explained in

Compare how 9 books explain scraping →

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.