Chapter 87: Prometheus and Grafana Monitoring
87.2 Prometheus architecture — scrape, TSDB, PromQL
Story. Omar joined an Accenture-style platform team in Hyderabad. His manager drew three boxes: targets expose /metrics, Prometheus scrapes them on a schedule and writes samples into its TSDB, then humans and Alertmanager query with PromQL. Omar stopped thinking Prometheus "receives pushes from every app" — the default model is pull (scrape).
Why
If you confuse push and pull, you misconfigure jobs and wonder why "nothing arrives". Prometheus pulls. You must list scrape targets (or discover them).
What
- Scrape — Prometheus HTTP GETs a metrics URL on an interval.
- Target — One endpoint that speaks the Prometheus text format (often
:9100/metricsfor node_exporter). - TSDB — Prometheus time-series database on local disk (retention is configurable).
- PromQL — The query language for graphs, rules and alerts.
- Job / instance — Labels Prometheus adds:
jobis the scrape job name;instanceis usually host:port.
How
- Run Prometheus with a
prometheus.ymlthat lists scrape configs. - Confirm
GET /metricsworks on each target with curl. - Open Prometheus UI → Status → Targets; all should be UP.
- Run a PromQL query in the Graph tab.
Example 1: Minimal scrape config shape
global:
scrape_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets: ["10.0.1.23:9100"]
What it shows: Every 15 seconds Prometheus scrapes http://10.0.1.23:9100/metrics and stores samples under job node.
Example 2: Check targets via API
curl -s http://127.0.0.1:9090/api/v1/targets | head -c 200; echo
Output
{"status":"success","data":{"activeTargets":[{"discoveredLabels":...
What it shows: The API answers. In the UI, green UP means scrape works; red DOWN means network, path or auth failed.
Ravindra Bagale's Tip
Default Prometheus is pull. Pushgateway exists for short batch jobs — do not use it for normal long-running services.
Default Prometheus pull आहे. Pushgateway short batch jobs साठी — सामान्य long-running services साठी नको.
Default Prometheus pull है. Pushgateway short batch jobs के लिए — सामान्य long-running services के लिए नहीं.
Quick quiz
Q1. Does Prometheus usually push or pull metrics?
Pull — it scrapes HTTP /metrics endpoints.
Q2. What is TSDB here?
The local time-series database inside Prometheus.
Q3. What is PromQL?
The query language used for graphs, recording rules and alerts.
Did you understand? Let us try it once more.