Introduction
Prometheus is a powerful open-source monitoring system designed for collecting metrics from targets, storing them efficiently, and allowing users to query and analyze them in real time. In this blog we’ll learn how to install Prometheus on Ubuntu server, which will serve as the monitoring server.
Step 1: Download and Install Prometheus
Download the latest stable Prometheus release:
wget https://github.com/prometheus/prometheus/releases/download/v2.37.6/prometheus-2.37.6.linux-amd64.tar.gz
Replace the version number with the latest one if needed.
Extract the tarball:
tar xvfz prometheus-2.37.6.linux-amd64.tar.gz
Remove the archive (optional):
rm prometheus-2.37.6.linux-amd64.tar.gz
Create necessary directories:
sudo mkdir /etc/prometheus /var/lib/prometheus
Move into the extracted directory:
cd prometheus-2.37.6.linux-amd64
Move Prometheus binaries to the system path:
sudo mv prometheus promtool /usr/local/bin/
Move config and support files:
sudo mv prometheus.yml /etc/prometheus/
sudo mv consoles/ console_libraries/ /etc/prometheus/
Verify the installation:
prometheus --version
Expected output:
prometheus, version 2.37.6
Step 2: Configure Prometheus as a systemd Service
Create a Prometheus system user:
sudo useradd -rs /bin/false prometheus
Set directory ownership:
sudo chown -R prometheus: /etc/prometheus /var/lib/prometheus
Create a systemd service file:
sudo vim /etc/systemd/system/prometheus.service
Paste the following configuration:
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.enable-lifecycle \
--log.level=info
[Install]
WantedBy=multi-user.target
Reload systemd and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable prometheus
Start Prometheus:
sudo systemctl start prometheus
Check status:
sudo systemctl status prometheus
You should see active (running) status.
Step 3: Access the Prometheus Web UI
Open a browser and go to:
http://<your-server-ip>:9090
You’ll see the Prometheus web UI. It’s currently monitoring only itself.
Conclusion
Successfully installed and configured Prometheus on Ubuntu server, running it as a systemd service. This sets the stage for monitoring other systems by adding them to the prometheus.yml configuration later.
Setting up Prometheus for efficient system monitoring can be challenging without the right expertise. If you’re looking for reliable assistance on how to install Prometheus on Ubuntu or need complete Server Management services, our experienced engineers are here to help