How to Install Prometheus on Ubuntu 22.04
Prometheus is an open-source systems monitoring and alerting toolkit, widely used for metrics collection and analysis.
Prerequisites
- An Ubuntu 22.04 VPS
- A user with
sudoprivileges - Basic knowledge of Linux commands
Update Your System
sudo apt update && sudo apt upgrade -y
Create a Prometheus User
sudo useradd --no-create-home --shell /bin/false prometheus
Create Directories
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
Download Prometheus
Check the Prometheus download page for the latest version. Example for v3.4.0:
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v3.4.0/prometheus-3.4.0.linux-amd64.tar.gz
tar xvf prometheus-3.4.0.linux-amd64.tar.gz
cd prometheus-3.4.0.linux-amd64
Move binaries and set permissions:
sudo mv prometheus promtool /usr/local/bin/
sudo mv prometheus.yml /etc/prometheus/
sudo chown -R prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool /etc/prometheus /var/lib/prometheus
Configure Prometheus Service
sudo nano /etc/systemd/system/prometheus.service
Paste:
[Unit]
Description=Prometheus
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.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
Save and exit.
Start and Enable Prometheus
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
sudo systemctl status prometheus
Configure Firewall (Optional)
If ufw is enabled:
sudo ufw allow 9090/tcp
sudo ufw reload
Prometheus runs by default on port 9090.
Access Prometheus Web UI
Open your browser and go to:
http://your-server-ip:9090

You should see the Prometheus dashboard.
Configure Targets (Optional)
Edit /etc/prometheus/prometheus.yml to add scrape targets:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
Reload Prometheus configuration without restarting:
sudo systemctl reload prometheus
Summary
You now have Prometheus running on Ubuntu 22.04.
For production:
- Use reverse proxy with NGINX for HTTPS access
- Enable firewall rules
- Consider node_exporter or other exporters to monitor system metrics
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS