Docs / Monitoring & Logging / Setting Up Prometheus and Grafana Monitoring Stack

Setting Up Prometheus and Grafana Monitoring Stack

By Admin · Jan 22, 2026 · Updated Apr 24, 2026 · 4 views · 3 min read

Managing prometheus effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for grafana configuration, along with best practices for production environments.

Prerequisites

  • A registered domain name (for public-facing services)
  • Open ports: 3000 (Grafana), 9090 (Prometheus)
  • Docker installed (for containerized monitoring)
  • Basic familiarity with the Linux command line
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)

Stack Installation

The grafana component plays a crucial role in the overall architecture. Understanding how it interacts with prometheus will help you make better configuration decisions.


# docker-compose.yml for monitoring stack
version: '3.8'
services:
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus_data:/prometheus
    ports:
      - "9090:9090"
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    volumes:
      - grafana_data:/var/lib/grafana
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=changeme
    restart: unless-stopped

volumes:
  prometheus_data:
  grafana_data:

Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.

Dashboard Configuration

When scaling this setup, consider vertical scaling (adding more RAM/CPU) first, as it's simpler to implement. Horizontal scaling adds complexity but may be necessary for high-traffic applications.


# prometheus.yml
global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.

Advanced Settings

The grafana component plays a crucial role in the overall architecture. Understanding how it interacts with prometheus will help you make better configuration decisions.

  • Use connection pooling for database connections
  • Scale vertically before scaling horizontally
  • Implement caching at every appropriate layer
  • Start with the minimum required resources

Common Issues and Solutions

  • Connection timeout: Verify your firewall rules allow traffic on the required ports. Use ss -tlnp to confirm the service is listening on the expected port.
  • High memory usage: Review the configuration for memory-related settings. Reduce worker counts or buffer sizes if running on a low-RAM VPS.
  • Service won't start: Check the logs with journalctl -xe -u prometheus. Common causes include port conflicts, missing configuration files, or insufficient permissions.

Summary

You've successfully configured prometheus on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.

Was this article helpful?