A pull model collects metrics by having the monitoring system periodically fetch them from monitored systems. Prometheus calls these fetches scraping and queries configured endpoints such as /metrics. 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
A Prometheus configuration sets a default 10-second interval, names scrape jobs, selects metric paths, and identifies targets through static configuration or DNS service discovery. section 9.3
Choose target discovery according to the deployment:
- Use static targets for a single container or a small fixed deployment. section 9.3
- Use DNS service discovery to find multiple containers for a service and scrape them at scale. section 9.3
- Check scaling behavior: a single-container component may produce unexpected results when DNS returns several addresses, while a multi-container component can be scraped across all addresses. section 9.3
Verify scaled scraping
Scale the access-log service to three containers, generate requests, and aggregate the resulting metric with sum(access_log_total) without(hostname, instance). section 9.3



