Install Prometheus Node Exporter on Bare-Metal Linux

To install the Prometheus Node Exporter directly onto a bare-metal Linux server without using Docker, you want to set it up as a native system service. This ensures it starts automatically when the server reboots and runs quietly in the background.

Here is the step-by-step production setup guide. You can do this manually on one server, or drop these steps into your Ansible workflow.

Step 1: Create a Dedicated System User

For security, Node Exporter should never run as root. Create a system user with no login shells or home directory.

Bash

sudo useradd --no-create-home --shell /bin/false node_exporter

Step 2: Download and Extract the Binary

Navigate to the /tmp folder, download the latest stable release of Node Exporter, and extract it.

Bash

cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
tar -xvf node_exporter-1.8.2.linux-amd64.tar.gz

(Note: You can check the Prometheus Downloads page to see if a newer version is available and change the version number accordingly.)

Step 3: Move the Binary into System Path

Move the executable binary to /usr/local/bin so it can be executed system-wide, and assign ownership to the user you created in Step 1.

Bash

sudo mv node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter

Clean up the remaining installation files you no longer need:

Bash

rm -rf node_exporter-1.8.2.linux-amd64*

Step 4: Create a Systemd Service File

To manage Node Exporter like any other Linux service (e.g., systemctl start), create a systemd service definition file.

Open a new file using your preferred text editor:

Bash

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

Paste the following configuration into the file:

Ini, TOML

[Unit]
Description=Prometheus 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 and exit the file (in Nano, press Ctrl+O, Enter, then Ctrl+X).

Step 5: Start and Enable Node Exporter

Reload the systemd manager to recognize your new service configuration, start Node Exporter, and enable it so it boots up automatically with the server.

Bash

sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
Verify it’s running:

Check the status of the service to ensure there are no errors:

Bash

sudo systemctl status node_exporter

You can also verify that it is successfully broadcasting metrics by hitting its port (9100) via curl:

Bash

curl http://localhost:9100/metrics

If you see a wall of text containing metrics starting with node_..., the installation was a complete success.

Step 6: Update Your Central Prometheus Server

Just like you did with your Docker containers, you must now tell your central Prometheus server to scrape this physical machine. Add the bare metal server’s IP address under your node-host-os job configuration in your central prometheus.yml file:

YAML

  - job_name: 'node-host-os'
    static_configs:
      - targets: ['192.168.1.50:9100'] # Your existing Docker hosts
      - targets: ['192.168.1.85:9100'] # Your new bare metal server IP
        labels: 
          instance: 'bare-metal-01'

Reload or restart your central Prometheus container, and the bare-metal server will instantly feed into your existing Grafana Node Exporter Full dashboard!

Leave a Reply