LocalHake

Tutorial

Node Exporter Service

How to install Node Exporter as a Service on Ubuntu 24.04

Hake HardwarePublished Updated ~7 minintermediate

This post contains paid links (affiliate) — how that works.


▶ Watch this build on YouTube
Contents

Introduction

This guide will provide instructions on how to install Node Exporter as a service in Ubuntu 24.04.

Prerequisites

Prometheus should be set up. Grafana should be connected to your Prometheus instance.

Download and Install node_exporter

Navigate to the node_exporter download and locate the release with the "Latest" tag. At the time of this wiki that is node_exporter-1.8.2.linux-amd64.tar.gz and it will be used as an example in future commands within this wiki.

Download the latest version to the home directory:

bash
wget -P ~/ https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz

Extract the downloaded file:

bash
tar -xvf ~/node_exporter-1.8.2.linux-amd64.tar.gz

Move the extracted files:

bash
sudo mv ~/node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/

Remove the unneeded files:

bash
rm -rf ~/node_exporter-1.8.2.linux-amd64*

Create the node_exporter user:

bash
sudo useradd -r -s /bin/false -c "Node Exporter service account" -d /nonexistent node_exporter
  • '-r': Creates a system account with a UID < 1000, typically used for system services.
  • '-s /bin/false': Disables shell access for the user.
  • '-c' "Node Exporter service account": Adds a comment for clarity.
  • '-d /nonexistent': Sets the home directory explicitly to a non-existent directory, further ensuring the account is restricted.

Set the user permissions:

bash
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter

Create the service:

bash
sudo nano /etc/systemd/system/node_exporter.service

Add the following configuration:

/etc/systemd/system/node_exporter.serviceini
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

Save with Ctrl+X, Y, Enter.

Reload the daemon:

bash
sudo systemctl daemon-reload

Start the service:

bash
sudo systemctl start node_exporter

Enable service to start on boot:

bash
sudo systemctl enable node_exporter

Verify the status:

bash
sudo systemctl status node_exporter

You should see it is enabled and active

Terminal output of sudo systemctl status node_exporter showing the service as enabled and active (running)

Update Prometheus Config

Update the Config

Open up the prometheus config:

bash
sudo nano /etc/prometheus/prometheus.yml

Then add a new job for node_exporter:

yaml
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']
        labels:
          instance: '<hostname>'

If the PC that you are installing node_exporter on is not the host that is running prometheus, then you should use the IP of the host that you are installing node_exporter on instead of localhost.

Restart the prometheus service:

bash
sudo systemctl restart prometheus

Verify Target is Up

To be sure the node_exporter target was loaded, check the web frontend for Prometheus. Click the "Status" menu item in the navbar and then the "Targets" menu item to see all connected targets

Prometheus web UI Targets page showing node_exporter (1/1 up) with endpoint in UP state

Importing the Dashboard

There is a default dashboard that you can import to get started. Open up Grafana, go to "Dashboards" and then click the button "New", from the dropdown select "Import". Then enter 1860 where it says "URL or ID". Then click "Load"

I usually make the name a bit more descriptive and change the UID slightly as well. Then select the Prometheus data source you set up. Finally click "Import"

Grafana import dashboard options dialog showing Name, Folder, UID, and Prometheus data source fields

You should see the dashboard load with the default layout.

Grafana Node Exporter dashboard showing Quick CPU/Mem/Disk gauges and Basic CPU and Memory time-series charts

And that's it! You can now monitor your PC easily from anywhere. You can even add alerts and other cool things, but that is outside the scope of this guide.

Gear used