Skip to content

Step-by-step guide to install and configure Prometheus on Ubuntu/Debian for system monitoring and observability.

Notifications You must be signed in to change notification settings

M-Tayyab06/Prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus Setup Guide (Ubuntu/Debian)

License Stars Issues PRs Welcome Ubuntu Monitoring

🚀 Prometheus Installation on Ubuntu

Welcome! This guide will walk you through installing and running Prometheus on an Ubuntu system step-by-step.


🛠️ Requirements

  • Ubuntu 20.04+ system
  • Terminal access with sudo privileges

⚙️ Step-by-Step Setup

🔄 1. Update the System

Keep your system packages up to date:

sudo apt update && sudo apt upgrade -y

👤 2. Create Prometheus User

Create a dedicated system user for Prometheus:

sudo useradd --no-create-home --shell /bin/false prometheus

📥 3. Download Prometheus

Download the latest release from GitHub:

wget https://github.com/prometheus/prometheus/releases/download/v2.51.2/prometheus-2.51.2.linux-amd64.tar.gz

tar xvf prometheus-2.51.2.linux-amd64.tar.gz
cd prometheus-2.51.2.linux-amd64

📂 4. Move Binaries

Move the main binaries to your system PATH:

sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/

🗂️ 5. Setup Directories

Create required directories and copy configuration:

sudo mkdir -p /etc/prometheus
sudo mkdir -p /var/lib/prometheus
sudo cp -r consoles /etc/prometheus
sudo cp -r console_libraries /etc/prometheus
sudo cp prometheus.yml /etc/prometheus/

Set proper ownership:

sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus

🔧 6. Create Systemd Service

Create the systemd service file:

sudo tee /etc/systemd/system/prometheus.service<<EOF

Paste this configuration:

[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.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

🟢 7. Start & Enable Prometheus

sudo systemctl daemon-reexec
sudo systemctl enable prometheus
sudo systemctl start prometheus

Check status:

sudo systemctl status prometheus

🌐 8. Verify Installation

Open your browser and navigate to:

http://localhost:9090
OR
http://your_public_ip:9090

You should see the Prometheus Dashboard. image


✅ Next Steps

🔸 Install Node Exporter to monitor system metrics
🔸 Integrate with Grafana for visual dashboards
🔸 Define alerting rules in prometheus.yml


📁 Directory Structure

/etc/prometheus/
├── prometheus.yml
├── consoles/
└── console_libraries/