./node_exporter is fine for quick tests, but it has two limitations: it runs in the foreground and it won’t start automatically after a reboot. To let systemd manage node_exporter — so you can use systemctl start node_exporter, systemctl status node_exporter, and have it start on boot — create a system user, place the binary in a standard location, and provide a systemd service unit.
Quick local vs systemd commands:
These steps assume you have already downloaded and extracted the node_exporter tarball and are in the extracted directory.
1. Move the binary, create a system user, set ownership
Copy the binary to a standard location, create a non-privileged system user, and set ownership so the service runs with least privilege.--no-create-homeand--shell /sbin/nologinensure the account is non-interactive.chmod 0755makes the binary executable for the system user.- If you want to run node_exporter on a non-default port or bind to localhost, you can later add flags to the systemd unit’s
ExecStart(example shown below).
2. Create the systemd service unit
Create/etc/systemd/system/node_exporter.service with the following content:
- Add startup flags to
ExecStart, for example to bind to localhost:ExecStart=/usr/local/bin/node_exporter --web.listen-address=127.0.0.1:9100
- To provide environment variables, use
Environment=or anEnvironmentFile=.
3. Reload systemd, start and enable the service
Reload the systemd manager configuration, start the service immediately, check its status, and enable it so it starts on boot.- View logs:
sudo journalctl -u node_exporter -f - Check whether the unit file syntax is valid:
systemd-analyze verify /etc/systemd/system/node_exporter.service - If you change the unit, re-run
sudo systemctl daemon-reloadandsudo systemctl restart node_exporter.
Be careful exposing the metrics endpoint publicly. node_exporter does not authenticate requests. If the host is internet-facing, bind node_exporter to
127.0.0.1:9100 or restrict access via firewall rules.4. Verify metrics are being served
Usecurl or a browser to confirm metrics are available on the expected endpoint:
To have Prometheus scrape this target, add it to your
prometheus.yml scrape configuration (for example, using localhost:9100 if Prometheus runs on the same host). See Prometheus scrape configuration docs: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_configsTroubleshooting checklist
- Service won’t start: run
sudo journalctl -u node_exporter -b --no-pagerand inspect the logs. - Port already in use: check
ss -ltnp | grep 9100or adjust--web.listen-address. - Permissions issues: verify file ownership
ls -l /usr/local/bin/node_exporterand thatUser=node_exporterexists. - Unit changes not applied: run
sudo systemctl daemon-reloadbeforerestart.
Links and references
- Prometheus scrape configuration: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_configs
- systemd documentation: https://www.freedesktop.org/wiki/Software/systemd/
- node_exporter GitHub releases: https://github.com/prometheus/node_exporter/releases