Getting pmm right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including mysql and monitoring considerations.
Stack Installation
If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.
# 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:
The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.
Dashboard Configuration
The mysql component plays a crucial role in the overall architecture. Understanding how it interacts with pmm will help you make better configuration decisions.
# prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
- job_name: 'pmm'
static_configs:
- targets: ['localhost:9090']
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Alert Rule Setup
Security should be a primary consideration when configuring pmm. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
# 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:
The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.
- Enable automatic security updates for critical patches
- Review log files weekly for anomalies
- Keep your system packages updated regularly
- Monitor disk space usage and set up alerts
- Test your backup restore procedure monthly
Summary
You've successfully configured pmm 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.