How to install prometheus on debian vpsHere’s a guide detailing how to install Prometheus on Debian VPS:

What is Prometheus?

Prometheus is an open-source, systems monitoring and alerting toolkit designed to collect and analyze metrics from servers, applications, and services. Initially developed at SoundCloud, Prometheus is now a popular Cloud Native Computing Foundation (CNCF) project widely adopted in cloud-native environments.

Key Features:

  • Time-Series Data: Efficiently stores metrics as timestamped values.
  • Multi-dimensional Data Model: Metrics identified by labels, offering powerful querying.
  • PromQL Querying: Robust, flexible query language to analyze collected data.
  • Pull-based Model: Actively scrapes metrics from HTTP endpoints of monitored services.
  • Alerting and Notifications: Built-in alert system triggering based on defined thresholds.
  • Scalable and Reliable: Easy integration with cloud environments and supports clustering and federation.
  • Integration-friendly: Works seamlessly with tools like Grafana, Kubernetes, and Docker.

Common Use Cases:

  • Server and infrastructure monitoring
  • Application performance tracking
  • Kubernetes and container orchestration metrics
  • Custom metrics collection and analysis
  • Proactive alerting and issue detection

Prometheus is valued for its simplicity, flexibility, and effectiveness in delivering real-time insights for improved system reliability and performance.
Launch 100% ssd debian vps from $2. 49/mo!

How to Install Prometheus on Debian VPS: A Step-by-Step Guide

Follow these steps to quickly install Prometheus on your Debian VPS.

  1. Update Your System

    First, ensure your Debian VPS is up-to-date:

    sudo apt update sudo apt upgrade -y
  2. Create Prometheus User

    Create a dedicated Prometheus user without shell access for security purposes:

    sudo useradd --no-create-home --shell /usr/sbin/nologin prometheus
  3. Download Prometheus

    Visit the Prometheus release page to check the latest stable version. This guide uses version 2.52.0 as an example:

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

    Extract the archive:

    tar xvf prometheus-2.52.0.linux-amd64.tar.gz
  4. Set Up Prometheus Directories and Permissions

    Move the Prometheus binary files to the appropriate directories:

    sudo mkdir -p /etc/prometheus sudo mkdir -p /var/lib/prometheus sudo cp prometheus-2.52.0.linux-amd64/prometheus /usr/local/bin/ sudo cp prometheus-2.52.0.linux-amd64/promtool /usr/local/bin/ sudo cp -r prometheus-2.52.0.linux-amd64/consoles /etc/prometheus sudo cp -r prometheus-2.52.0.linux-amd64/console_libraries /etc/prometheus sudo cp prometheus-2.52.0.linux-amd64/prometheus.yml /etc/prometheus/

    Set the correct ownership for directories:

    sudo chown -R prometheus:prometheus /etc/prometheus sudo chown -R prometheus:prometheus /var/lib/prometheus sudo chown prometheus:prometheus /usr/local/bin/prometheus sudo chown prometheus:prometheus /usr/local/bin/promtool
  5. Configure Prometheus Systemd Service

    Create a systemd service file to easily manage Prometheus as a service:

    sudo nano /etc/systemd/system/prometheus.service

    Add 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.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install] WantedBy=multi-user.target

    Save and exit (CTRL+X, then Y and press Enter).

  6. Start and Enable Prometheus Service

    Reload systemd to apply changes and start Prometheus:

    sudo systemctl daemon-reload sudo systemctl start prometheus sudo systemctl enable prometheus

    Check Prometheus status to verify it’s running:

    sudo systemctl status prometheus
  7. Adjust Firewall Rules (Optional but Recommended)

    Allow Prometheus to be accessed via port 9090 if your server uses UFW firewall:

    sudo ufw allow 9090/tcp sudo ufw reload
  8. Access Prometheus Web Interface

    Now, Prometheus should be accessible through your web browser at:

    http://your_server_ip:9090

    You will see the Prometheus web UI indicating the service is running successfully.

  9. Verify Prometheus Metrics

    To confirm Prometheus is properly collecting data, navigate to:

    http://your_server_ip:9090/metrics

    This endpoint displays metrics in plain text, indicating active data collection.

  10. Configuring Targets (Optional)

    Edit the prometheus.yml configuration file to add more targets or scrape endpoints:

    sudo nano /etc/prometheus/prometheus.yml

    Add your custom targets and restart the Prometheus service:

    sudo systemctl restart prometheus
  11. Monitoring Enhancements (Recommended):

    • Node Exporter: Install and configure Node Exporter for detailed system-level metrics.
    • Grafana: Connect Prometheus with Grafana for powerful visualization dashboards.
  12. ✅Configure Prometheus with Certbot for Automated SSL

    1. Install Nginx and Certbot

      First, install Nginx and Certbot on your Debian VPS:

      sudo apt update sudo apt install nginx certbot python3-certbot-nginx -y
    2. Configure Nginx Reverse Proxy for Prometheus

      Create an Nginx configuration file for Prometheus:

      sudo nano /etc/nginx/sites-available/prometheus

      Paste the following:

      server { listen 80; server_name prometheus.example.com; # replace with your domain location / { proxy_pass http://localhost:9090; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

      Save and close the file (CTRL + X, then Y, and Enter).

    3. Activate the Nginx Site Configuration

      Activate your new site by creating a symbolic link:

      sudo ln -s /etc/nginx/sites-available/prometheus /etc/nginx/sites-enabled/

      Check Nginx configuration and restart the service:

      sudo nginx -t sudo systemctl restart nginx
    4. Configure UFW Firewall (Optional but Recommended)

      Allow HTTP and HTTPS traffic:

      sudo ufw allow 'Nginx Full' sudo ufw reload
    5. Generate SSL Certificates Automatically with Certbot

      Run Certbot to automatically create and install the SSL certificate for your Prometheus domain:

      sudo certbot --nginx -d prometheus.example.com
      

      Certbot will:

      • Obtain a free certificate from Let’s Encrypt
      • Adjust your Nginx configuration automatically
      • Set up automatic HTTPS redirection (recommended)
    6. Test Your SSL Configuration

      Navigate to your Prometheus URL in your browser:

      https://prometheus.example.com

      You should see a valid HTTPS connection secured with SSL/TLS.

    7. Automate Certificate Renewal

      Certbot automatically schedules renewal through a cron/systemd timer. Confirm renewal configuration with:

      sudo certbot renew --dry-run

      If successful, no further manual renewal steps are needed.

Launch 100% ssd debian vps from $2. 49/mo!

Conclusion

You have successfully installed Prometheus on your Debian VPS, providing robust monitoring and data visualization capabilities. With this setup, you’ll enjoy enhanced visibility, proactive troubleshooting, and overall improved reliability.

Enjoy monitoring your infrastructure!

Share this:
Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg