Skip to content

Node Exporter Installation

I am using linux ubuntu machine for this installation. I spin up linux ubuntu machine in AWS cloud, and it is up and running. I have also connected EC2 instance using iterm terminal in my Mac machine.

Step 1

Go to the website "https://prometheus.io/download/#node_exporter" and find the latest version of node exporter tar file. Copy the link for that tar file.

obs_28

Step 2

Run the command "wget " in the terminal to download the tar file.

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

obs_29

Step 3

Untar the downloaded file using the command "tar -xvzf .

tar -xvzf node_exporter-1.8.2.linux-amd64.tar.gz

obs_30

Step 4

Navigate to node exporter directory (unzipped one)

obs_31

Step 5

Start the node exporter executable file

obs_32

Step 6

Open the browser and enter node exporter server IP followed by port number 9100.

obs_33


Node exporter is up and running now. However, if I close the terminal where node exporter executable is running or my EC2 instance is down, then the node exporter also stops. Hence, this is not the ideal way to run the node exporter. The ideal way of running node exporter is to install and run as a service (systemd).


The ideal way of running node exporter as a service.

Step 1 - Create a system user for node exporter

System username is node_exporter. Before doing it, we need to ensure node_exporter user is not created yet.

To do so, run the command cat /etc/passwd | grep -i node_exporter If it returns value, it means node_exporter user is already available in the system.

We can create system user now. To create the user, run the below commands

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

obs_35

To check if the user is created successfully, run the command

cat /etc/passwd | grep -i node_exporter

obs_36

Step 2 - Copy the executable file to bin location

To copy the node exporter to bin location, run the below commands

sudo cp node_exporter /usr/local/bin/

obs_34

Step 3 - Assign permission and ownership to the system user

To assign the ownership to node exporter user, run the below commands

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

obs_37

Step 4 - Create a service file for node exporter

Update the below content in the node exporter service file located at /etc/systemd/system/node_exporter.service

[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
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

obs_38

Step 5 - Reload the daemon service

To do so, run the below command

systemctl daemon-reload

obs_39

Step 6 - Start the node exporter service

To do so, run the below command

systemctl start node_exporter.service
obs_40

Step 7 - Check the status of the node exporter service

To do so, run the below command

systemctl status node_exporter.service
obs_41

Step 8 - Enable the node exporter service

To do so, run the below command. This will ensure that the node exporter service automatically starts at system booting.

systemctl enable node_exporter.service
obs_42

Step 9 - Check the metrics are populated

To do so, run the below command

curl localhost:9100/metrics
obs_43

Integrate Node Exporter with Prometheus

Prometheus scrapes the target and pulls the metrics. So, it should know what the target is prior to pull the metrics. Prometheus target configuration is configured in the prometheus.yml file by default. Hence, we need to update the configuration file with the target details of node exporter server details. After this change, restart the prometheus. Then, Prometheus will start to scrape the node metrics after restarting the prometheus.

Step 1 - Check Prometheus server status and Node exporter status

Connect the prometheus server in the terminal and run the following command.

systemctl status prometheus.service
obs_44

Connect the node exporter machine in the terminal and run the following command.

systemctl status node_exporter.service

obs_45

Step 2 - Update prometheus configuration file

Add the node server ip address in the target section to ensure prometheus knows what machine it needs to scrape.

  - job_name: "Node server"
    scrape_interval: 10s
    scrape_timeout: 5s
    metrics_path: /metrics
    static_configs:
      - targets: ["172.31.84.187:9100"]

obs_46

Step 3 - Restart Prometheus Server

Connect the prometheus server in the terminal and run the following command.

systemctl restart prometheus.service
obs_47

Step 4 - Check Prometheus server status

Connect the prometheus server in the terminal and run the following command.

systemctl status prometheus.service
obs_44

Step 5 - Check Prometheus UI for target status

Open the browser and enter the .

obs_48

Click on the menu "Status -> Targets"

obs_49

As we see, prometheus server is able to understand the node service and where it is running, what is the current state, etc.

If we go to the "graph" menu, and type "node" you will be able to see all the metrics related to node service.

obs_50

That's all. Simple, isn't it?