How does Prometheus collect metrics — what is the pull model and scraping? [Basic]
Answer
Prometheus normally uses a pull model: it periodically scrapes HTTP endpoints exposed by targets. Each target publishes metrics in the Prometheus exposition format, and Prometheus stores the scraped samples in its TSDB.
Technical explanation
The pull model makes target health visible through the up metric and keeps scraping configuration under platform control.
Service discovery dynamically finds targets from Kubernetes, EC2, Consul, file configs, or static configs.
Push is reserved for limited cases such as short-lived batch jobs that cannot be scraped reliably.
Hands-on example
Example: an app exposes /metrics on port 8080. Prometheus discovers the pod through Kubernetes labels, scrapes every 30 seconds, and records up{job='checkout'} plus application metrics. If scraping fails, up becomes 0 and target status shows the scrape error.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- What is a scrape target, and how does service discovery find them? [Basic]
- What is the difference between a counter and a gauge? [Basic]
- What are the Prometheus metric types (counter, gauge, histogram, summary)? [Basic]
- What is the difference between an exporter and instrumenting your app directly? [Basic]
- What is a time series in Prometheus, and how is it identified (metric name plus labels)? [Basic]
- What is the Pushgateway, and why is it discouraged for most cases? [Basic]
- What is PromQL, and what is an instant vector versus a range vector? [Basic]
- What is the difference between a symptom-based and a cause-based alert, and which is better? [Basic]