The Ultimate Guide to Installing Prometheus

Prometheus is a powerful open-source monitoring and alerting system that collects metrics via a pull model and offers flexible querying through PromQL. Let’s walk through how to install and configure it from scratch, covering both manual and Docker methods—so you can choose based on your setup.


1. What is Prometheus? 🤔

  • Prometheus is a time-series database designed for monitoring and alerting, written in Go under the Apache 2.0 license. (Wikipedia)
  • It pulls metrics from configured targets (e.g., applications or exporters) periodically. (Wikipedia)

2. Installation Methods

Choose a method that matches your environment:

  • Manual (precompiled binary) — Ideal for standalone deployments
  • Docker — Quick and clean for containers
  • Helm on Kubernetes — Great for scalable clusters

Let’s dive into each.


3. Manual Installation on Linux

Step 1: Create a Prometheus User & Directories

sudo groupadd --system prometheus
sudo useradd --system --no-create-home --shell /sbin/nologin -g prometheus prometheus

sudo mkdir /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus

(Medium, Bindplane)

Step 2: Download & Extract Prometheus

cd /tmp
curl -L -o prometheus.tar.gz \
  https://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz
tar xvf prometheus.tar.gz
cd prometheus-2.47.2.linux-amd64

(Bindplane)

Step 3: Install Binaries & Assets

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

sudo cp -r consoles console_libraries /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus/consoles /etc/prometheus/console_libraries

(Medium, DevOpsCube)

Step 4: Configure Prometheus

Create /etc/prometheus/prometheus.yml:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']

(prometheus.io, DevOpsCube)

Set ownership:

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml

(DevOpsCube)

Step 5: Create Systemd Service

Create /etc/systemd/system/prometheus.service:

[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

(DevOpsCube)

Step 6: Start & Verify

sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
sudo systemctl status prometheus

Access the UI at: http://<your-server-ip>:9090/


4. Docker Installation

Want fast setup with Docker?

docker run -d \
  -p 9090:9090 \
  -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
  --name prometheus \
  prom/prometheus

For data persistence:

docker volume create prometheus-data
docker run -d \
  -p 9090:9090 \
  -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
  -v prometheus-data:/prometheus \
  --name prometheus \
  prom/prometheus

(prometheus.io)


5. Kubernetes with Helm

Got a cluster and Helm? Use this method:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/prometheus --namespace monitoring --create-namespace

(AWS Documentation)

Verify pods:

kubectl get pods -n monitoring

Access UI via port-forwarding:

kubectl port-forward -n monitoring svc/prometheus-server 9090:9090

(AWS Documentation)


6. What’s Next? 🏁

  • Configure additional scrape targets (e.g., Node Exporter, app exporters)
  • Connect with Grafana for dashboarding
  • Set up Alertmanager for alerts and notifications
  • Scale with remote write or long-term storage setups

7. Summary Table

Setup MethodSteps Summary
ManualCreate Prometheus user & directories → Download & extract binaries → Install and configure → Create systemd service → Start & access UI
DockerRun official Docker image with config bind mount → Add a volume for persistent data
KubernetesAdd Helm repo → Install via Helm chart → Port-forward dashboard access

8. User Insights 🗣️

From r/PrometheusMonitoring:

“So here is a short guide: … Prometheus is the one who comes to a target and takes metrics from it. This process is called scraping.” (Reddit)


Final Takeaway

Whether you’re using bare-metal, Docker, or Kubernetes, Prometheus offers a fast and flexible installation path with great community support. Pick the deployment style that suits your environment, and start monitoring in minutes!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *