0. Introduction
Prometheus is a monitoring tool that helps teams see how their servers, applications, and services are performing in real time. It enables the rapid identification of issues, helps maintain service stability, and improves performance.
The key feature of Prometheus is its pull model: the server itself polls data sources via specific HTTP addresses (endpoints). This simplifies load management and the automatic discovery of targets. This approach distinguishes Prometheus from many other systems, which rely on a push model where data must be actively sent to the server.
0.1 Requirements
Before you start, you will need:
A VPS with Ubuntu 22.04 or 24.04;
SSH access with root or sudo privileges;
Node Exporter installed and running on port
9100. You can install it by following our guide.
To check if Node Exporter is running, use this command:
sudo systemctl status node_exporter
The service should be in the active (running) state.
1. Installing Prometheus
1.1 Download Prometheus
Connect to your VPS via SSH.
First, go to the temporary directory:
cd /tmp
Now download Prometheus from the official GitHub repository:
wget https://github.com/prometheus/prometheus/releases/download/v3.15.1/prometheus-3.15.1.linux-amd64.tar.gz
In this example we use version 3.15.1. If you want to know whether a newer version is available, check the official Prometheus download page.
Before unpacking the archive, let's verify its SHA256 checksum:
echo "6a726885328ad9efebbf36e876ce2fb6225468a71fd1e7ce3ba666d5f4d97a84 prometheus-3.15.1.linux-amd64.tar.gz" | sha256sum -c -
You should get this output:
prometheus-3.15.1.linux-amd64.tar.gz: OK
If the checksum is different, do not install the downloaded file.
1.2 Extract and install Prometheus
Extract the archive:
tar -xzf prometheus-3.15.1.linux-amd64.tar.gz
Next, copy the executable files to /usr/local/bin/:
sudo install -m 0755 prometheus-3.15.1.linux-amd64/prometheus /usr/local/bin/
sudo install -m 0755 prometheus-3.15.1.linux-amd64/promtool /usr/local/bin/
Check that the installation was successful:
prometheus --version
If everything went well, you will see the version information of Prometheus.
2. Configuring Prometheus
2.1 Create a dedicated user
It is not a good idea to run Prometheus as root, so we will create a separate system user for it.
Create the user:
sudo useradd --system --no-create-home --user-group --shell /usr/sbin/nologin prometheus
Then create the directories for the configuration file and for the collected metrics:
sudo mkdir -p /etc/prometheus /var/lib/prometheus
Now give the prometheus user ownership of the data directory:
sudo chown prometheus:prometheus /var/lib/prometheus
2.2 Configure metric collection
Create the Prometheus configuration file:
sudo nano /etc/prometheus/prometheus.yml
Add the following content:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['127.0.0.1:9090']
- job_name: 'node_exporter'
static_configs:
- targets: ['127.0.0.1:9100']
Save the file and close the editor.
What does this configuration do?
scrape_interval: 15s- Prometheus collects metrics every 15 seconds.127.0.0.1:9090- Prometheus collects its own metrics.127.0.0.1:9100- Prometheus collects the server metrics from Node Exporter.
Both services are on the same VPS, so we don't need the public IP address of the server here.
Now let's check the configuration for errors:
promtool check config /etc/prometheus/prometheus.yml
If there are no errors, the output will contain this line:
SUCCESS: /etc/prometheus/prometheus.yml is valid prometheus config file syntax
3. Creating a Prometheus Service
We want Prometheus to work in the background and start automatically after a reboot, so we will create a systemd service for it.
Create the service file:
sudo nano /etc/systemd/system/prometheus.service
Paste the following content:
[Unit]
Description=Prometheus Monitoring
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus \
--web.listen-address=127.0.0.1:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target
Save the file.
With these settings Prometheus saves the collected metrics in /var/lib/prometheus and listens only on 127.0.0.1:9090.
Reload systemd so it picks up the new service:
sudo systemctl daemon-reload
Now start Prometheus and enable it to run on boot:
sudo systemctl enable --now prometheus
Check the status of the service:
sudo systemctl status prometheus
You should see this line:
Active: active (running)
That's it, Prometheus is now running and collecting metrics from Node Exporter.
4. Accessing Prometheus
4.1 Open the web interface
Prometheus has a web interface where you can check the collected metrics and see graphs.
In our setup this interface is available only from the VPS itself. To open it from your own computer, you can use an SSH tunnel.
Open a terminal on your computer and run this command:
ssh -L 9090:127.0.0.1:9090 YOUR_USERNAME@YOUR_VPS_IP
Replace YOUR_USERNAME and YOUR_VPS_IP with your SSH username and the IP address of your VPS.
Leave this SSH session open while you work with the interface.
Then open this address in the browser on your computer:
http://127.0.0.1:9090
You will see the Prometheus web interface.
Please note: Prometheus listens only on localhost, so you don't need to open port 9090 to the public.
4.2 Check Node Exporter connectivity
In the browser, go to this page:
http://127.0.0.1:9090/targets
Here you can see all the services that Prometheus is monitoring.
There should be two targets:
prometheusnode_exporter
Both of them must have the status UP.
If Node Exporter is DOWN, make sure that its service is running and that port 9100 is reachable locally.
4.3 View server metrics
Open the query interface of Prometheus:
http://127.0.0.1:9090/query
To check if Node Exporter is responding, enter this query:
up{job="node_exporter"}
Then click Execute.
If the value is 1, Prometheus is able to collect metrics from Node Exporter. The value 0 means that the target is not available.
Here is one more query, it shows the available memory of your server:
node_memory_MemAvailable_bytes / 1024 / 1024 / 1024
The result is shown in GiB.
You can also switch to the graph view to see how this value changes over time.
For more PromQL queries and examples, refer to the official Prometheus query examples or the Node Exporter monitoring guide.
5. Conclusion
Prometheus addresses core monitoring tasks - from metric collection to alerting and visualization. Implementing the system reduces the risk of prolonged downtime, enhances service stability, and accelerates incident response.




