Skip to main content
This guide explains how to configure a Prometheus server to scrape metrics from one or multiple nodes. After installing Prometheus and setting up your nodes with Node Exporters to expose metrics, you must explicitly configure Prometheus to discover and scrape these targets using its pull-based model. The configuration is maintained in the prometheus.yaml file, typically found in the /etc/prometheus directory. Below is a basic Prometheus configuration example:
In this configuration:
  • The global section defines default parameters, which can be inherited or overridden by other sections.
  • The scrape_configs section specifies the target endpoints for scraping metrics.

Detailed Scrape Configuration

Prometheus uses the scrape_configs block to identify targets for metric collection. In this enhanced example, additional parameters—such as scrape_interval, scrape_timeout, and sample_limit—allow you to fine-tune the scraper’s behavior.
Key points in this configuration:
  • Global defaults specify a 1-minute scrape interval and a 10-second timeout.
  • The node job overrides these defaults, setting a 15-second interval and a 5-second timeout.
  • The static_configs block clearly indicates the target IP and port for scraping metrics.
Additional configuration blocks like alerting, rule_files, remote_read, remote_write, and storage are available for extended use cases.

Customizing Job Configurations

When adding a new job under scrape_configs, you must specify details such as the job name, scrape interval, timeout, scheme (HTTP/HTTPS), and the metrics path. By default, Prometheus scrapes metrics from the /metrics endpoint; however, customization is possible if your target uses a different endpoint. For instance, the following configuration demonstrates how to scrape two targets over HTTPS using a custom metrics path:
This configuration shows:
  • A job called nodes that scrapes every 30 seconds.
  • A 3-second scrape timeout.
  • Usage of HTTPS for securing the connection.
  • Changing the default metrics path from /metrics to /stats/metrics.
  • Two specified target nodes with their respective IP addresses and ports.
The section below summarizes common adjustable options in the scrape_configs:
These options allow you to tailor the timing, endpoint, and authentication settings for each job as needed.

Updating the Prometheus Configuration

After modifying the prometheus.yaml file, Prometheus does not automatically reload changes. You must restart the Prometheus process. If running Prometheus manually (e.g., using ./prometheus), you can simply press Ctrl+C and restart the process. For Prometheus running under systemd, use one of the following methods:
Or restart via systemd with:
Consider an updated prometheus.yaml configuration that adds a new job for scraping a Node Exporter on a specific Linux machine:
In this updated configuration:
  • The prometheus job continues to scrape Prometheus itself.
  • A new node job is added to scrape a Linux machine running Node Exporter on IP 192.168.1.168 at port 9100.
After updating the configuration, restart the Prometheus service to apply the changes:
Remember to save your changes to prometheus.yaml and restart Prometheus to apply the new configuration.

Verifying the Configuration

After restarting Prometheus, open the Prometheus web UI and navigate to the “Status” -> “Targets” page. Here you can inspect all configured targets and their scrape status. Both the Prometheus target and the new node target should display an “UP” status for successful metric collection.
The image shows a Prometheus monitoring dashboard displaying two active targets, "node" and "prometheus," both in an "UP" state with their respective endpoints and scrape details.
You can further verify the configuration by executing queries such as:
A returned value of 1 confirms that the instances are active and functional.
This article demonstrated how to modify your Prometheus configuration file to add new scrape targets and adjust parameters such as scrape interval, timeout, and metrics path. By following these steps, Prometheus can successfully collect metrics from both itself and external nodes running Node Exporters.

Watch Video