Install Prometheus Node Exporter on Linux [2 Steps]

In this article we are going to cover How to monitor Linux server using Prometheus and Node Exporter/ Install Prometheus Node Exporter on Linux (Ubuntu, RedHat/CentOS/Amazon Linux2).

Before Installation of Node Exporter you need Prometheus server to be running, Follow below articles to Install Prometheus and Grafana on Linux OS.

Prerequisite: 

  • Good internet connectivity 
  • Security Groups Configured properly
  • Any web Browser

Security Groups Configured on EC2 Instances

  • Port 9090 — Prometheus Server
  • Port 9100 — Prometheus Node Exporter

#1.Download and Install Prometheus Node Exporter on Linux

Node Exporter collects the metrics of your system such as Memory usage, CPU usage, RAM, disk space, etc.

To install Node Exporter first navigate to Prometheus official download page, Scroll down and you will get node_exporter section and then select Linux OS for amd64.

Now right click on node exporter and copy link address

Install Prometheus Node Exporter on Linux [2 Steps] 1
node exporter

Now lets run the copied URL with wget command

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

Unzip the downloaded the file using below command

tar xvfz node_exporter-*.*-amd64.tar.gz

Move the binary file of node exporter to /usr/local/bin location.

sudo mv node_exporter-*.*-amd64/node_exporter /usr/local/bin/

Create a node_exporter user to run the node exporter service.

sudo useradd -rs /bin/false node_exporter

#2.Create a node_exporter service file in the /etc/systemd/system directory

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

Paste the below content in your service file

[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

Now lets start and enable the node_exporter service using below commands 

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

Lets Check the Status of Node Exorter:

sudo systemctl status node_exporter
Install Prometheus Node Exporter on Linux [2 Steps] 2
node exporter

Now, node exporter would be exporting metrics on port 9100. 

You can see all the server metrics by visiting your server URL on /metrics as shown below.

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

#3.Configure the Node Exporter as a Prometheus target

Now to scrape the node_exporter lets instruct the Prometheus by making a minor change in prometheus.yml file

sudo nano /etc/prometheus/prometheus.yml
-job_name: 'Node_Exporter'

    scrape_interval: 5s

    static_configs:

      - targets: ['<Server_IP_of_Node_Exporter_Machine>:9100']

After changing in config file you need to restart to prometheus

Now restart the Prometheus Service

sudo systemctl restart prometheus

Hit the URL in your web browser to check weather our target is successfully scraped by Prometheus or not

https://localhost:9100/targets
Install Prometheus Node Exporter on Linux [2 Steps] 3
target 2

Conclusion:

In this article we have covered How to monitor Linux server using Prometheus and Node Exporter/ Install Prometheus Node Exporter on Linux (Ubuntu, RedHat/CentOS/Amazon Linux2).

Reference:

Monitoring Linux host metrics with the Node Exporter

Shweta Mamidwar

I am Shweta Mamidwar working as a Intern in Product Company. Likes to share knowledge.

Leave a Comment

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

Share via
Copy link
Powered by Social Snap