World map

 

BM: Baca dalam Bahasa Melayu

World O2: Counters

Scraping and targets

You will learn: how Prometheus collects numbers by visiting targets, and how to read up.

Checked with Prometheus 3 on 1 Nov 2026

The problem

Kedai Kancil’s helpers each keep a counter. How should the control room get the numbers?

Pick one answer.

Watch

bash
curl -s localhost:9100/metrics | grep 'node_load1 '
# HELP node_load1 1m load average.
# TYPE node_load1 gauge
node_load1 11.37
curl reads a machine's metrics page. Three lines about node_load1 come back.

A target: One address Prometheus scrapes, like node-exporter:9100. Its job and instance become labels. shows its numbers as plain text at /metrics. This one is a machine, at port 9100.

Try it

Tell Prometheus about the machine. Add a second job called node.

Add a job named node with the target node-exporter:9100.

prometheus.yml8 lines

How a computer reads it

  • globalmap · 1 keys
    • scrape_interval15stext
  • scrape_configslist · 1 items
    • item 1map · 2 keys
      • job_nameprometheustext
      • static_configslist · 1 items
        • item 1map · 1 keys
          • targetslist · 1 items
            • item 1localhost:9090text

Each visit is a scrape: Prometheus visits a target on a timer and copies its numbers from /metrics..

Try it

Your first PromQL: The language you use to ask Prometheus questions. query is one word. For every target, Prometheus writes up: 1 if the scrape worked, 0 if not.

Type up and press Run.

Metrics in this data (tap to add):

Time 0 is when the data starts. The query looks back from the eval time.

Predict

At 12m, shop-2 shows up = 0. What does that mean?

Pick one answer.

Check

A config mistake. Real error first: tap the line that says what is wrong.

Tap the line that names the problem.

0 of 1 found

You did it!

You can now point Prometheus at a target and read up.

Go deeper (optional)

The job name becomes the job label, and host:port becomes instance. Every scrape also writes scrape_duration_seconds. Real rep: a small control room on your laptop. Save these two files in a folder.

# prometheus.yml
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: node
    static_configs:
      - targets: ["node-exporter:9100"]
# compose.yaml
services:
  prometheus:
    image: quay.io/prometheus/prometheus:v3.13.5
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
  node-exporter:
    image: quay.io/prometheus/node-exporter:v1.12.1
    ports:
      - "9100:9100"

Real mission

  1. mkdir kedai-watch && cd kedai-watch
  2. docker compose up -d
  3. docker compose exec prometheus promtool check config /etc/prometheus/prometheus.yml
  4. curl -s localhost:9100/metrics | grep 'node_load1 '
  5. docker compose down

0 of 7 steps done · Your ticks are saved.