This guide demonstrates setting up Node Exporter as a systemd service to run in the background and start automatically at boot.
This guide demonstrates how to set up Node Exporter as a systemd service. By following these steps, Node Exporter will run in the background and automatically start at boot. This setup is very similar to the Prometheus configuration but involves fewer files.──────────────────────────────
Step 1: Copy the Node Exporter Binary and Create a Dedicated User
Begin by copying the Node Exporter binary to /usr/local/bin. Next, create a non-login user called node_exporter to run the service securely, and update the binary’s ownership to this user:
Create the service file at /etc/systemd/system/node_exporter.service with the following content. This configuration ensures that systemd waits until the network is online prior to starting Node Exporter, and that the process runs under the node_exporter user:
After creating the service file, reload the systemd daemon to recognize the new service. Then, start and enable the service to ensure it launches automatically on boot:
Once Node Exporter is running, verify that it is serving metrics by sending an HTTP request to its metrics endpoint:
Copy
Ask AI
curl localhost:9100/metrics
The output should include metric information similar to this snippet:
Copy
Ask AI
node_vstat_pswpout 0# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.# TYPE process_cpu_seconds_total counterprocess_cpu_seconds_total 0# HELP process_max_fds Maximum number of open file descriptors.# TYPE process_max_fds gaugeprocess_max_fds 524288...# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.promhttp_metric_handler_requests_total{status="200"} 0promhttp_metric_handler_requests_total{status="500"} 0promhttp_metric_handler_requests_total{status="503"} 0
This confirms that your monitoring system (such as Prometheus) can successfully scrape metrics from Node Exporter.──────────────────────────────
The final step involves configuring your monitoring solution to scrape Node Exporter metrics. In the following section, we will explain how to set up Prometheus to effectively monitor Node Exporter.Happy Monitoring!For more details on setting up and maintaining Prometheus, refer to the Prometheus documentation.