Skip to content

Instantly share code, notes, and snippets.

@nwesterhausen
Last active October 12, 2024 06:02
Show Gist options
  • Save nwesterhausen/d06a772cbf2a741332e37b5b19edb192 to your computer and use it in GitHub Desktop.
Save nwesterhausen/d06a772cbf2a741332e37b5b19edb192 to your computer and use it in GitHub Desktop.
node_exporter installation on ubuntu

Installing node_exporter

Steps to install node_exporter

  1. Add user for node_exporter

    sudo useradd --no-create-home --shell /bin/false node_exporter
  2. Download node_exporter

    cd
    wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
  3. Extract node_exporter

    tar xvf node_exporter-0.18.1.linux-amd64.tar.gz
  4. Copy node_exporter to /opt

    sudo mv node_exporter-0.18.1.linux-amd64 /opt/node_exporter
    sudo chown -R node_exporter:node_exporter /opt/node_exporter
  5. Create service file for systemd

    sudo nano /etc/systemd/system/node_exporter.service
  6. Fillin as follows:

    [Unit]
    Description=Node Exporter
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=node_exporter
    Group=node_exporter
    Type=simple
    ExecStart=/opt/node_exporter/node_exporter --collector.systemd
    
    [Install]
    WantedBy=multi-user.target
    
  7. Start the service with systemd and verify it runs

    sudo systemctl daemon-reload
    sudo systemctl start node_exporter && sudo journalctl -f --unit node_exporter
  8. On the prometheus server, dont' forget to add the static config for the collection of data!

@adv4000
Copy link

adv4000 commented Apr 24, 2024

Don't forget to add systemctl enable node_exporter

@bayronq
Copy link

bayronq commented May 12, 2024

❯ sudo systemctl status node_exporter
× node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Sat 2024-05-11 19:23:23 CST; 5s ago
Duration: 2ms
Process: 8434 ExecStart=/opt/node_exporter/node_exporter --collector.systemd (code=exited, status=203/EXEC)
Main PID: 8434 (code=exited, status=203/EXEC)
CPU: 1ms

May 11 19:23:23 vmdocker.bayronq.local systemd[1]: Started Node Exporter.
May 11 19:23:23 vmdocker.bayronq.local systemd[8434]: node_exporter.service: Failed to locate executable /opt/node_exporter/node_exporter: Permission denied
May 11 19:23:23 vmdocker.bayronq.local systemd[8434]: node_exporter.service: Failed at step EXEC spawning /opt/node_exporter/node_exporter: Permission denied
May 11 19:23:23 vmdocker.bayronq.local systemd[1]: node_exporter.service: Main process exited, code=exited, status=203/EXEC
May 11 19:23:23 vmdocker.bayronq.local systemd[1]: node_exporter.service: Failed with result 'exit-code'.

@EAAZZYY
Copy link

EAAZZYY commented Jul 4, 2024

Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment