{"id":870,"date":"2018-06-14T06:46:48","date_gmt":"2018-06-14T06:46:48","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=870"},"modified":"2018-06-14T06:46:48","modified_gmt":"2018-06-14T06:46:48","slug":"monitor-linux-servers-prometheus-node-exporter","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=870","title":{"rendered":"How To Monitor Linux Servers Using Prometheus Node Exporter"},"content":{"rendered":"<p>Node exporter is the best way to collect all the Linux server related metrics and statistics for monitoring.<\/p>\n<h2 id=\"monitor-linux-servers-using-prometheus\">Monitor Linux Servers Using Prometheus<\/h2>\n<p>In this guide, you will learn how to setup Prometheus node exporter on a Linux server to export all node level metrics to the Prometheus server.<\/p>\n<h3 id=\"before-you-begin\">Before You Begin<\/h3>\n<ol>\n<li>Prometheus Node Exporter needs Prometheus server to be up and running. If you would like to setup Prometheus, please see the <a href=\"https:\/\/devopscube.com\/install-configure-prometheus-linux\/\" rel=\"noopener noreferrer\">Prometheus setup guide for Linux<\/a>.<\/li>\n<li>Port 9100 opened in server firewall as Prometheus reads metrics on this port.<\/li>\n<\/ol>\n<h3 id=\"setup-node-exporter-binary\">Setup Node Exporter Binary<\/h3>\n<p><strong>Step 1:<\/strong> Download the latest node exporter package. You should check the <a href=\"https:\/\/prometheus.io\/download\/?ref=devopscube.com\" rel=\"noopener noreferrer\">Prometheus downloads section<\/a> for the latest version and update this command to get that package.<\/p>\n<pre><code>cd \/tmp\ncurl -LO https:\/\/github.com\/prometheus\/node_exporter\/releases\/download\/v0.18.1\/node_exporter-0.18.1.linux-amd64.tar.gz<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Unpack the tarball<\/p>\n<pre><code>tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Move the node export binary to \/usr\/local\/bin<\/p>\n<pre><code>sudo mv node_exporter-0.18.1.linux-amd64\/node_exporter \/usr\/local\/bin\/<\/code><\/pre>\n<h3 id=\"create-a-custom-node-exporter-service\">Create a Custom Node Exporter Service<\/h3>\n<p><strong>Step 1:<\/strong> Create a node_exporter user to run the node exporter service.<\/p>\n<pre><code>sudo useradd -rs \/bin\/false node_exporter<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Create a node_exporter service file under systems.<\/p>\n<pre><code>sudo vi \/etc\/systemd\/system\/node_exporter.service<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Add the following service file content to the service file and save it.<\/p>\n<pre><code>[Unit]\nDescription=Node Exporter\nAfter=network.target\n\n[Service]\nUser=node_exporter\nGroup=node_exporter\nType=simple\nExecStart=\/usr\/local\/bin\/node_exporter\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Reload the system daemon and star the node exporter service.<\/p>\n<pre><code>sudo systemctl daemon-reload\nsudo systemctl start node_exporter<\/code><\/pre>\n<p><strong>Step 5:<\/strong> check the node exporter status to make sure it is running in the active state.<\/p>\n<pre><code>sudo systemctl status node_exporter<\/code><\/pre>\n<p><strong>Step 6:<\/strong> Enable the node exporter service to the system startup.<\/p>\n<pre><code>sudo systemctl enable node_exporter<\/code><\/pre>\n<p>Now, node exporter would be exporting <strong>metrics on port 9100.<\/strong><\/p>\n<p>You can see all the server metrics by visiting your server URL on \/metrics as shown below.<\/p>\n<pre><code>http:\/\/&lt;server-IP&gt;:9100\/metrics<\/code><\/pre>\n<h3 id=\"configure-the-server-as-target-on-prometheus-server\">Configure the Server as Target on Prometheus Server<\/h3>\n<p>Now that we have the node exporter up and running on the server, we have to add this server a target on the Prometheus server configuration.<\/p>\n<p>Note: This configuration should be done on the Prometheus server.<\/p>\n<p><strong>Step 1:<\/strong> Login to the Prometheus server and open the prometheus.yml file.<\/p>\n<pre><code>sudo vi \/etc\/prometheus\/prometheus.yml<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Under the scrape config section add the node exporter target as shown below. Change 10.142.0.3 with your server IP where you have setup node exporter. Job name can be your server hostname or IP for identification purposes.<\/p>\n<pre><code>- job_name: 'node_exporter_metrics'\n  scrape_interval: 5s\n  static_configs:\n    - targets: ['10.142.0.3:9100']<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Restart the prometheus service for the configuration changes to take place.<\/p>\n<pre><code>sudo systemctl restart prometheus<\/code><\/pre>\n<p>Now, if you check the target in prometheus web UI (http:\/\/&lt;prometheus-IP&gt;:9090\/targets) , you will be able to see the status as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-node-exporter-status-2.png\" class=\"kg-image\" alt=\"prometheus node exporter status\" loading=\"lazy\" width=\"2000\" height=\"787\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/prometheus-node-exporter-status-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/prometheus-node-exporter-status-2.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/prometheus-node-exporter-status-2.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-node-exporter-status-2.png 2002w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Also, you can use the Prometheus expression browser to query for node related metrics. Following are the few key node metrics you can use to find its statistics.<\/p>\n<pre><code>node_memory_MemFree_bytes\nnode_cpu_seconds_total\nnode_filesystem_avail_bytes\nrate(node_cpu_seconds_total{mode=\"system\"}[1m]) \nrate(node_network_receive_bytes_total[1m])<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-node-exporter-metric-queries-2.png\" class=\"kg-image\" alt=\"prometheus node exporter metric queries\" loading=\"lazy\" width=\"2000\" height=\"701\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/prometheus-node-exporter-metric-queries-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/prometheus-node-exporter-metric-queries-2.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/prometheus-node-exporter-metric-queries-2.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w2400\/2025\/03\/prometheus-node-exporter-metric-queries-2.png 2400w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Follow &#8220;<a href=\"https:\/\/devopscube.com\/integrate-visualize-prometheus-grafana\/\" rel=\"noopener noreferrer\">Integrate And Visualize Prometheus Metrics In Grafana<\/a>&#8221; blog to visualize the node exporter metrics in Grafana.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/monitor-linux-servers-prometheus-node-exporter\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Monitor Linux Servers Using Prometheus Node Exporter \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/monitor-linux-servers-prometheus-node-exporter\/<\/p>\n","protected":false},"author":1,"featured_media":871,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-870","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=870"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/870\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/871"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}