Ravindra BagaleCourses & study guides मराठी

Chapter 87: Prometheus and Grafana Monitoring

DevOps

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).

Targets expose metrics. Prometheus scrapes into TSDB. PromQL serves graphs and alerts.
Targets expose metrics. Prometheus scrapes into TSDB. PromQL serves graphs and alerts.

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/metrics for 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: job is the scrape job name; instance is usually host:port.

How

  1. Run Prometheus with a prometheus.yml that lists scrape configs.
  2. Confirm GET /metrics works on each target with curl.
  3. Open Prometheus UI → Status → Targets; all should be UP.
  4. 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.

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.