Contents
1. Introduction
Prometheus is an open source monitoring system and time series database which is very lightweight and has a good alerting mechanism.
2. Install and Configure Prometheus
This guide explains how to install and configure the latest Prometheus on a Linux server (debian,Ubuntu,Centos….).
2.1. Prerequisites
- Ensure that you have sudo access to the Linux server
- The server has access to the internet for downloading Prometheus.
- Prometheus port 9090 should be opened on the server.
2.2. Setup Prometheus Binaries
Step 1: Update the package repositories
1 2 3 4 |
in Ubuntu/Debian: sudo apt-get update -y in centos/RHEL: sudo yum update -y |
Step 2: Go to official Prometheus downloads page and get the download link for Linux binary.

Step 3: Create a Prometheus user, required directory.
1 |
sudo useradd --no-create-home --shell /bin/false prometheus |
Step 4: Download the source using curl, untar it and rename the extracted folder to prometheus-files.
1 2 3 |
wget https://github.com/prometheus/prometheus/releases/download/v2.7.1/prometheus-2.7.1.linux-amd64.tar.gz -P /tmp/ tar -xvf /tmp/prometheus-2.7.1.linux-amd64.tar.gz -C /tmp/ mv /tmp/prometheus-2.7.1.linux-amd64 /etc/prometheus |
Step 4: make prometheus user as the owner of /etc/prometheus directory.
1 |
sudo chown prometheus:prometheus /etc/prometheus |
2.3. Setup Prometheus Configuration
All the prometheus configurations should be present in /etc/prometheus/prometheus.yml file.
Step 1: update the prometheus.yml file.
1 |
sudo vim /etc/prometheus/prometheus.yml |
Step 2: Copy the following contents to the prometheus.yml file
1 2 3 4 5 6 7 8 9 10 |
global: scrape_interval: 10s scrape_configs: - job_name: 'prometheus' scrape_interval: 5s static_configs: - targets: ['localhost:9090'] metrics_path: /prometheus/metrics |
Step 3: Change the ownership of the file to prometheus user.
1 |
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml |
2.4. Setup Prometheus Service File
Step 1: Create a prometheus service file in /etc/systemd/system/ directory
1 |
sudo vim /etc/systemd/system/prometheus.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# Ansible managed [Unit] Description=Prometheus service After=network-online.target Wants=network.target [Service] Redémarrer = on-failure #Changez cette ligne si vous téléchargez le # Prometheus sur différents chemins utilisateur ExecStart=/etc/prometheus/prometheus --config.file=/etc/prometheus/prometheus.yml --log.level=info --query.timeout=1m --storage.tsdb.path=/etc/prometheus/data --storage.tsdb.retention=15d --web.console.libraries=console_libraries --web.console.templates=consoles --web.external-url=http://localhost/prometheus --web.listen-address=:9090 Restart=always RestartSec=20 TimeoutSec=300 User=prometheus Group=prometheus StandardOutput=journal StandardError=journal [Installer] WantedBy = multi-user.target |
Step 3: Reload the systemd service to register the prometheus service and start the prometheus service.
1 2 |
sudo systemctl daemon-reload sudo systemctl start prometheus |
Check the prometheus service status using the following command.
1 |
sudo systemctl status prometheus |

2.5. Access Prometheus Web UI
Now you will be able to access the prometheus UI on 9090 port of the prometheus server.
1 |
http://<prometheus-ip>:9090/prometheus/graph |

3. Install and Configure Node_exporter
Node exporter is the best way to collect all the Linux server related metrics of our current system (such as load average and free memory)
Step 1: Download node_exporter in this link downloads and download the latest version, like so:
1 2 3 |
sudo wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz -P /tmp/ tar -xvf /tmp/node_exporter-0.17.0.linux-amd64.tar.gz -C /tmp/ mv /tmp/node_exporter-0.17.0.linux-amd64 /etc/node-exporter |

Step 2: Create a node-exporter user, required directory.
1 |
sudo useradd --no-create-home --shell /bin/false node-exporter |
Step 3: make node-exporter user as the owner of /etc/node-exporter directory.
1 |
sudo chown node-exporter:node-exporter /etc/node-exporter |
Step 4: Setup Prometheus Service Filen
Create a node_exporter service file in /etc/systemd/system/ directory
1 |
sudo vim /etc/systemd/system/node_exporter.service |
1 2 3 4 5 6 7 8 9 10 11 12 |
[Unit] Description=Node Exporter Wants=network-online.target After=network-online.target [Service] User=node-exporter ExecStart=/etc/node-exporter/node_exporter [Install] WantedBy=default.target |
Step 5: SReload the systemd service to register the node_exporter service and start the prometheus service.
1 2 |
sudo systemctl daemon-reload sudo systemctl start node_exporter |
Check the prometheus service status using the following command.
1 |
sudo systemctl status node_exporter |

Step 6: we can set the service to always run at boot and start it:
1 |
sudo systemctl enable node_exporter <br>sudo systemctl start node_exporter |
Step 7: Add node exporter config in prometheus configuration to scrap the metrics
1 |
sudo vim /etc/prometheus/prometheus.yml |
in scrape_configs: section add node exporter target
1 2 3 4 5 6 7 8 9 10 11 |
global: scrape_interval: 10s scrape_configs: # # # - job_name: 'node_exporter_metrics' scrape_interval: 5s static_configs: - targets: ['localhost:9100'] |
Step 7: Finally restart prometheus services to take in considiration our change.
1 |
sudo systemctl restart prometheus |
In prometheus dashboard verify that node exporter is green in taget section as bellow

