Prometheus is an open source monitoring solution that stores all its data in a time series database. Prometheus has a multi-dimensional data-model and a powerful query language that is used to generate reports of the resources being monitored. This tutorial explains how to monitor a Linux server performance with Prometheus and Grafana.

Prometheus node exporter exports hardware and OS metrics exposed by *NIX kernels for consumption by Prometheus. This exporter is written in Go with pluggable metric collectors.

Similar Prometheus articles available on this blog are:

Monitoring Ceph Cluster with Prometheus and Grafana

How to Monitor BIND DNS server with Prometheus and Grafana

Monitoring MySQL / MariaDB with Prometheus in five minutes

How to Monitor Apache Web Server with Prometheus and Grafana in 5 minutes

Setup Procedure

  1. Install Prometheus and Grafana
  2. Install Prometheus Node Exporter on Linux servers to be monitored
  3. Configure Node Exporter
  4. Configure Prometheus server with Scrap jobs
  5. Add Dashboards to Grafana
  6. Start visualizing system metrics on Grafana

For installation of Prometheus and Grafana use:

Install Prometheus Server on CentOS 7 / Ubuntu / Debian

How to Install Grafana on Ubuntu and Debian

Install Grafana and InfluxDB on CentOS 7

Step 1: Add Prometheus system user

We’ll add a user account to run nod exporter service. It is safe since it doesn’t have access to the interactive shell and home directory.

sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

We added a system user called prometheus whose default group is prometheus.

Step 2: Download and Install Prometheus Node Exporter

Next is the latest release of Prometheus Node exporter:

curl -s | grep browser_download_url | grep linux-amd64 |  cut -d '"' -f 4 | wget -qi -

Extract the file downloaded:

tar xvf node_exporter-*linux-amd64.tar.gz

Move the downloaded file to the /usr/local/bin directory:

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

The version installed can be confirmed using the command:

$ node_exporter  --version
node_exporter, version 0.18.1 (branch: HEAD, revision: 3db77732e925c08f675d7404a8c46466b2ece83e)
  build user:       [email protected]
  build date:       20190604-16:41:18
  go version:       go1.12.5

Step 3: Configure Prometheus Node Exporter systemd / Init script

Collectors are enabled by providing a --collector.<name> flag.

Collectors that are enabled by default can be disabled by providing a --no-collector.<name>flag.

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

Add below content:


ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/node_exporter \
    --collector.cpu \
    --collector.diskstats \
    --collector.filesystem \
    --collector.loadavg \
    --collector.meminfo \
    --collector.filefd \
    --collector.netdev \
    --collector.stat \
    --collector.netstat \
    --collector.systemd \
    --collector.uname \
    --collector.vmstat \
    --collector.time \
    --collector.mdadm \
    --collector.zfs \
    --collector.tcpstat \
    --collector.bonding \
    --collector.hwmon \
    --collector.arp \
    --web.listen-address=:9100 \

Start the service and enable it to start on boot:

sudo systemctl start node_exporter
sudo systemctl enable node_exporter

Step 4: Configure firewall

If you have an active firewall on your server, e.g firewalld, ufw, open port 9100

sudo ufw allow 9100

For CentOS 7 system, use firewalld:

sudo firewall-cmd --add-port=9100/tcp --permanent
sudo firewall-cmd --reload

For Init Linux system like CentOS 6, you can use daemonize to start the service in the background.

Install daemonize:

sudo yum install daemonize
sudo apt-get install daemonize

Once installed, create node_exporter init script:

sudo vim /etc/init.d/node_exporter

Add below script:

# Author: Josphat Mutai, [email protected] ,
# node_exporter     This shell script takes care of starting and stopping Prometheus apache exporter
# chkconfig: 2345 80 80
# description: Prometheus apache exporter  start script
# processname: node_exporter
# pidfile: /var/run/

# Source function library.
. /etc/rc.d/init.d/functions


# GO CPU core Limit

#GOMAXPROCS=$(grep -c ^processor /proc/cpuinfo)

# Source config


start() {
    if [[ -f $PIDFILE ]] > /dev/null; then
        echo "node_exporter  is already running"
        exit 0

    echo -n "Starting node_exporter  service…"
    daemonize -u ${USER} -p ${PIDFILE} -l ${LOCKFILE} -a -e ${LOGFILE} -o ${LOGFILE} ${PROG} ${ARGS}
    echo ""
    return $RETVAL

stop() {
    if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
        echo "Service not running"
        return 1
    echo 'Stopping service…'
    #kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
    killproc -p ${PIDFILE} -d 10 ${PROG}
    [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
    return $RETVAL

status() {
    if [ -f "$PIDFILE" ] || kill -0 $(cat "$PIDFILE"); then
      echo "apache exporter  service running..."
      echo "Service PID: `cat $PIDFILE`"
      echo "Service not running"
     return $RETVAL

# Call function
case "$1" in
        echo "Usage: $0 {start|stop|restart}"
        exit 2

Create Arguments configuration file:

sudo vim /etc/sysconfig/node_exporter


"--collector.cpu \
--collector.diskstats \
--collector.filesystem \
--collector.loadavg \
--collector.meminfo \
--collector.filefd \
--collector.netdev \
--collector.stat \
--collector.netstat \
--collector.systemd \
--collector.uname \
--collector.vmstat \
--collector.time \
--collector.mdadm \
--collector.xfs \
--collector.zfs \
--collector.tcpstat \
--collector.bonding \
--collector.hwmon \
--collector.arp \

Test the script:

# /etc/init.d/node_exporter
Usage: /etc/init.d/node_exporter {start|stop|restart}

Step 5: Start the Prometheus node exporter service

For systemd, start using:

sudo systemctl start node_exporter
sudo systemctl enable node_exporter

For Init system use:

sudo /etc/init.d/node_exporter start
sudo chkconfig node_exporter on

You can verify using:

$ sudo /etc/init.d/node_exporter status
apache exporter  service running...
Service PID: 1970

$ sudo chkconfig --list | grep node_exporter
node_exporter 0:off   1:off   2:on    3:on    4:on    5:on    6:off

$ sudo ss -tunelp | grep 9100
tcp    LISTEN     0      128      :::9100                 :::*                   users:(("node_exporter",pid=16105,fd=3)) uid:997 ino:193468 sk:ffff8a0a76f52a80 v6only:0 <->

Step 6: Add exporter job to Prometheus

The second last step is to add a job to the Prometheus server for scraping metrics. Edit /etc/prometheus/prometheus.yml

# Linux Servers
  - job_name: apache-linux-server1
      - targets: ['']
          alias: server1

  - job_name: apache-linux-server2
      - targets: ['']
          alias: server2

Restart prometheus service for scraping to start

sudo systemctl restart prometheus

Test access to port 9100 from Prometheus server

$ telnet 9100
Connected to
Escape character is '^]'.

Step 7: Add Dashboard to Grafana

You can create your own Grafana dashboard or import from a collection of community shared dashboards. Below is a list of dashboards than has been created to show classical system metrics of your *NIX server.


For demo purposes, we’ll use the first dashboard with ID 159.

Add Prometheus data source

With Prometheus data source added to Grafana, Import Apache Grafana Dashboard by navigating to Dashboard > Import. Use 159 for Grafana Dashboard ID.

prometheus node exporter import dashboard min

Give it a descriptive name and select Prometheus data source added earlier.

prometheus node exporter import dashboard 02 min

Click “Import” button to start using the dashboard. After a few minutes, the metrics should start showing.

node exporter system dashboard min

That’s all. Feel free to customize the dashboard to fit your use case and share for others to benefit as well.

Monitoring MySQL / MariaDB with Prometheus in five minutes

How To Monitor Etcd Cluster with Prometheus and Grafana

How to Monitor Apache Web Server with Prometheus and Grafana in 5 minutes

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


  1. Great site and guide, thank you for writing it up. I found a type when creating the user. The user is missing a “s” at the end.

    sudo useradd -s /sbin/nologin –system -g prometheus prometheu


Please enter your comment!
Please enter your name here