🎓 A1Learner
🔍
0 of 50 lessons completed

Prometheus: Your First Scrape: Node Exporter

Node Exporter is a small program that reports numbers about the machine it runs on. This lesson adds it as a target and watches Prometheus scrape it.

The Node Exporter target

Add one job to prometheus.yml. It names the exporter and its port.

scrape_configs:
  - job_name: "node"
    static_configs:
      - targets: ["127.0.0.1:9100"]

Check the config file

promtool reads the file and reports any mistake before Prometheus loads it.

promtool check config prometheus.yml

Ask whether the target is up

The query up returns one series per target, with the value 1 for a healthy target. The lab ran Prometheus on port 19101; the learner's Compose stack uses 9090.

curl -s "http://127.0.0.1:19101/api/v1/query?query=up"

Example

promtool check config prometheus.yml

Key points

  • Node Exporter: a program that reports machine numbers, like CPU time and free memory.
  • An exporter turns something into numbers Prometheus can read, on a metrics page.
  • A target is one thing Prometheus scrapes, named by its address and port.
  • A job is a group of targets that do the same work, like every Node Exporter.
  • Targets live in the scrape_configs list in the file prometheus.yml.
  • The special series up is 1 when a target answers and 0 when it does not.

In this example, promtool checks the config file that lists the three lab targets: Prometheus itself, Node Exporter and ShopSentry. The word SUCCESS means the file is valid and safe to load. After loading it, the up query returned 1 for all three targets, so every scrape is working.

Note

Always check the config file before reloading, because Prometheus refuses to load a bad file.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What does the series up with value 1 mean for a target?