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
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.
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
- targetslist · 1 items
- item 1map · 1 keys
- item 1map · 2 keys
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.
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
Hint
Look for FAILED.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
mkdir kedai-watch && cd kedai-watchdocker compose up -ddocker compose exec prometheus promtool check config /etc/prometheus/prometheus.ymlcurl -s localhost:9100/metrics | grep 'node_load1 'docker compose down
0 of 7 steps done · Your ticks are saved.
Bahasa Melayu
Setiap pembantu Kedai Kancil simpan satu kaunter. Bagaimana bilik kawalan patut dapat nombornya?
Target tunjuk nombornya sebagai teks biasa di /metrics. Yang ini sebuah mesin, di port 9100.
Beritahu Prometheus tentang mesin itu. Tambah job kedua bernama node.
Setiap lawatan ialah satu scrape (kutip).
Query PromQL pertama anda hanya satu perkataan. Untuk setiap target, Prometheus tulis up: 1 kalau scrape berjaya, 0 kalau gagal.
Pada 12m, shop-2 tunjuk up = 0. Apa maksudnya?
Satu silap konfigurasi. Ralat sebenar dulu: tekan baris yang kata apa yang salah.
Kini anda boleh halakan Prometheus ke target dan baca up.
You finished this before. Practice is always welcome!
Official docs: Prometheus: getting started · Prometheus: configuration · Prometheus: jobs and instances · promtool
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?