Press "Enter" to skip to content

Prometheus Node Exporter

bist 0

Setup a Prometheus Node exporter on Ubuntu Server

In this guide I will be showing you how you can setup a Prometheus node exporter on Ubuntu 18.04 server f so that a Prometheus server can collect metrics from it.

Requirements

To follow this guide you will need the following:

  • A Ubuntu machine with root/sudo access
  • Raspberry pi

Downloading and Setting up the Node Exporter

First step is to head over to the Prometheus website and get a link for the latest version of the node exporter. Make sure this is set for the right architecture for your machine (arm64). You should then wget this. At the time of writing this document, it is v1.0.0-rc.0

sudo wget https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz

Once downloaded, we can then extract this

tar -xvf node_exporter*

Following this, we can move the node_exporter directory within to our /usr/local/bin directory

sudo mv node_exporter*/node_exporter /usr/local/bin

Adding a node_exporter user

We can now add a user to handle the exporting of our metrics. This user will be a system user (-r) who will be unable to get a shell (-s /bin/false)

sudo useradd -rs /bin/false node_exporter

Setting up the Node Exporter as a service

Now we can create a service for the node exporter. We can do this by creating a file

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

with the following contents

[Unit]
Description=Node Exporter
After=network.target

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

[Install]
WantedBy=multi-user.target

You can then save the file (Ctrl + o) and exit (Ctrl + x).

Start the service

We can now start the service, enable it so it starts on boot and view the status to make sure it started correctly

sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
sudo systemctl status node_exporter

If all goes well, you can access the metrics at

http://<server-IP>:9100/metrics

Adding new node to Prometheus

Once you have setup the node, you can add it to your prometheus by editing the yml file

sudo nano /etc/prometheus/prometheus.yml

In here, you will want to add/update the following

  - job_name: 'node_exporter_metrics'
    scrape_interval: 5s
    static_configs:
      - targets: ['<server-IP>:9100']

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.