Cloud Computing, DevOps

4 Mins Read

Learn Installation of Node Exporter on a Linux Server

Node Exporter is a Prometheus exporter for server level and OS level metrics with configurable metric collectors. It helps us in measuring various server resources such as RAM, disk space, and CPU utilization. Node exporter is a good solution to collect all the Linux server related metrics and statistics for monitoring.

Here, you will learn how to install the node exporter manually as well by Ansible playbook on a Linux server to export all node level metrics to the Prometheus server.

Prerequisites

  1. Prometheus server to be up and running to receive Node Exporter metrics.
  2. In the inbound rules of the server firewall, port 9100 should be opened for Prometheus server IP as Prometheus reads metrics on this port.

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Setup Node Exporter Binary

Step 1: Go to the official release page of Prometheus Node Exporter and copy the link of the latest version of the Node Exporter package according to your OS type. Then update the command to get that package.

Step 2: Unpack the tar file

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

Create a Custom Node Exporter Service

Step 1: Create a node_exporter service file in the /etc/systemd/system directory.

Step 2: Edit the file and add the below content in it. This will allow us to start node exporter as a service.

Step 3: Register the node exporter as a service in systemctl by reloading the system daemon and start the node exporter service.

Step 4: check the status of node exporter service to make sure it is active, and service is running.

Step 5: Finally, enable the node exporter service to the system startup so that service will be up and running even after the reboot of the machine.

Now, after starting the service, node exporter is ready to export metrics on port 9100.

To view all the server metrics, you can curl your server URL on /metrics, as shown below.

 

Configure the Server as Target on Prometheus Server

Now that we have successfully configured the node exporter on the server and it is ready to export metrics, we must add this server as a target on the Prometheus server configuration. This configuration we will do on the Prometheus server.

Step 1: SSH into the Prometheus machine and open the prometheus.yml file which is at location /etc/prometheus.

Step 2: Now, we need to create a new job for Node Exporter, which will fetch the required metrics. Add the new job under the scrape config segment as shown below. In the targets section, add the IP of your Node Exporter machine. Job name can be anything like your server hostname or IP for identification purposes but here we are using Node_Exporter.

Step 3: Now, restart the prometheus service to make our changes effective in the configuration using the below command.

Now, we have configured the node exporter job in the Prometheus configuration file; you can check the targets on the Prometheus web UI (http://<prometheus-IP>:9090/targets), The updated target will be reflected there under the Node_Exporter job. Please make sure the status of the target is active. If the target status is Down, then please check the connectivity between your Prometheus server and the target server.

Also, you can use the Prometheus graph (http://<prometheus-IP>:9090/graph) to query the metrics on the web UI and get the corresponding output in the form of graphs over time as well as the value. You can try with the below query metrics.

To install Node Exporter using an Ansible playbook, there are some prerequisites.

  1. There should be Ansible installed on your machine in which you want to install Node Exporter, and you must run the playbook on your localhost.
  2. If you are using a far Ansible workstation, the IP of your Ansible workstation should be whitelisted for SSH  ( Port 22 ) in the firewall of the machine where you want to install Node Exporter.

Node_Exporter.yml

Here, Two files are used, which are vars.yml  and init.service.j2.

vars.yml: It is having variables like userId, groupId, and version of the node exporter. Location: /home/ec2-user/vars.yml (for CentOS machines)

init.service.j2: It is the service file of node exporter. Location: /home/ec2-user/playbook/init.service.j2. (If the playbook directory is not there, then it needs to be created.)

vars.yml

 

init.service.j2

To install Node Exporter with Ansible, add the host IP of the destination machine in the hosts file located at /etc/ansible/hosts and use the below command.

Now, you can use this playbook to install Node Exporter in as many servers as you want at a time. Hope the steps mentioned above are clear. Watch this space for more blogs on monitoring and alerting.

f you want to learn more about Prometheus go to our website and check more courses on DevOps.

Please comment if you have any questions.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

WRITTEN BY Saurabh Jain

Saurabh Kumar Jain is a Subject Matter Expert working with CloudThat. He has experience in AWS, Microsoft Azure, and DevOps technologies. He is specialized in cloud security and architecture design. He also holds experience on various cloud and DevOps projects based on the cloud maturity model. He is an AWS Certified Security Speciality, AWS Certified Solutions Architect - Associate, Microsoft certified Azure Administrator and a certified Terraform Associate.

Share

Comments

  1. Eli

    Dec 30, 2022

    Reply

    I want to use node_rxporter as a metrics scraper but the target location is HTTPS and has a user/password. node_exporter only uses HTTP still, I don’t find any place ussing https?

  2. Sanket

    Oct 5, 2021

    Reply

    I think you will need to also create node_exporter user since the service is defined to start with User / Group as node_exporter

  3. Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!