The default prometheus.yml contains a job prometheus with targets: ["localhost:9090"]. What does it do, and why is it there?
Prometheus scrapes itself. The server exposes metrics about its own health and performance on /metrics at port 9090, and this job collects them like those of any exporter.
scrape_configs:
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
job_nameis added as the labeljob="prometheus"to every series this job scrapes.static_configs/targetsis a fixed list ofhost:portendpoints (as opposed to service discovery).- Defaults: path
/metrics, schemehttp, so the URL scraped ishttp://localhost:9090/metrics.
Why: the monitoring system should be monitored too: scrape durations, number of series, rule evaluation time, storage size. It also gives a working example out of the box.
To add a Windows and a Debian exporter, you append one job per target:
- job_name: "win"
static_configs:
- targets: ["windows-xxx.example:9182"]
- job_name: "deb"
static_configs:
- targets: ["debian-xxx.example:9100"]
YAML is indentation-sensitive, so a misaligned line stops Prometheus from starting. After systemctl restart prometheus, journalctl -eu prometheus.service shows config errors, and the /targets page shows whether each target is UP.
Go deeper:
Prometheus — Configuration (scrape_config) — every field of a scrape job and its default.
Prometheus — Getting started — the same self-scrape config, explained line by line.