pgSentinelConfiguration
Complete configuration guide for pgSentinel monitoring platform. Environment variables, Docker settings, and customization options.
Environment Variables
Complete reference for all configuration options
Database Configuration
DATABASE_URLRequiredPostgreSQL connection string
Example
Default
DB_HOSTOptionalPostgreSQL host (overrides DATABASE_URL)
Example
Default
DB_PORTOptionalPostgreSQL port (overrides DATABASE_URL)
Example
Default
DB_NAMEOptionalPostgreSQL database name (overrides DATABASE_URL)
Example
Default
DB_USEROptionalPostgreSQL username (overrides DATABASE_URL)
Example
Default
DB_PASSWORDOptionalPostgreSQL password (overrides DATABASE_URL)
Example
Default
Redis Configuration
REDIS_URLRequiredRedis connection string for caching
Example
Default
REDIS_HOSTOptionalRedis host (overrides REDIS_URL)
Example
Default
REDIS_PORTOptionalRedis port (overrides REDIS_URL)
Example
Default
REDIS_PASSWORDOptionalRedis password for authentication
Example
Default
Service Ports
BACKEND_PORTOptionalBackend API server port
Example
Default
FRONTEND_PORTOptionalFrontend web server port
Example
Default
WEBSITE_PORTOptionalMarketing website port
Example
Default
PROMETHEUS_PORTOptionalPrometheus metrics server port
Example
Default
GRAFANA_PORTOptionalGrafana dashboard port
Example
Default
Monitoring Configuration
METRICS_INTERVALOptionalMetrics collection interval in seconds
Example
Default
PROMETHEUS_RETENTIONOptionalPrometheus data retention period
Example
Default
GRAFANA_ADMIN_PASSWORDOptionalGrafana admin password
Example
Default
ALERT_EMAILOptionalEmail address for alerts
Example
Default
Security & Authentication
SECRET_KEYRequiredSecret key for JWT token signing
Example
Default
JWT_EXPIRE_HOURSOptionalJWT token expiration time in hours
Example
Default
CORS_ORIGINSOptionalAllowed CORS origins (comma-separated)
Example
Default
Docker Configurations
Docker Compose setups for different environments
Docker Compose Override
Override default settings using docker-compose.override.yml
# docker-compose.override.yml
version: '3.8'
services:
backend:
environment:
- DATABASE_URL=postgresql://user:pass@host:5432/db
- REDIS_URL=redis://redis:6379
- METRICS_INTERVAL=10
ports:
- "8000:8000"
frontend:
environment:
- NEXT_PUBLIC_API_URL=http://localhost:8000
ports:
- "3000:3000"
grafana:
environment:
- GF_SECURITY_ADMIN_PASSWORD=your-password
ports:
- "3001:3000"
prometheus:
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=30d'
ports:
- "9090:9090"Environment File
Create .env file for local development
# .env # Database Configuration DATABASE_URL=postgresql://postgres:password@localhost:5432/postgres DB_HOST=localhost DB_PORT=5432 DB_NAME=postgres DB_USER=postgres DB_PASSWORD=password # Redis Configuration REDIS_URL=redis://localhost:6379 REDIS_HOST=localhost REDIS_PORT=6379 # Service Ports BACKEND_PORT=8000 FRONTEND_PORT=3000 WEBSITE_PORT=3002 PROMETHEUS_PORT=9090 GRAFANA_PORT=3001 # Monitoring Configuration METRICS_INTERVAL=5 PROMETHEUS_RETENTION=15d GRAFANA_ADMIN_PASSWORD=admin123 ALERT_EMAIL=admin@example.com # Security SECRET_KEY=your-super-secret-key-here JWT_EXPIRE_HOURS=24 CORS_ORIGINS=http://localhost:3000,https://yourdomain.com
Production Docker Compose
Production-ready configuration with external services
# docker-compose.prod.yml
version: '3.8'
services:
backend:
image: pgsentinel/backend:latest
environment:
- DATABASE_URL=${DATABASE_URL}
- REDIS_URL=${REDIS_URL}
- SECRET_KEY=${SECRET_KEY}
- METRICS_INTERVAL=30
restart: unless-stopped
depends_on:
- postgres
- redis
frontend:
image: pgsentinel/frontend:latest
environment:
- NEXT_PUBLIC_API_URL=${API_URL}
restart: unless-stopped
depends_on:
- backend
postgres:
image: postgres:15
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
restart: unless-stopped
prometheus:
image: prom/prometheus:latest
volumes:
- ./monitoring/prometheus:/etc/prometheus
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=30d'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
restart: unless-stopped
grafana:
image: grafana/grafana:latest
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana:/etc/grafana/provisioning
restart: unless-stopped
volumes:
postgres_data:
prometheus_data:
grafana_data:PostgreSQL Configuration
Required PostgreSQL setup for optimal monitoring
Required Extensions
Enable these PostgreSQL extensions for full functionality
-- Connect to your PostgreSQL database psql -U postgres -d your_database -- Enable required extensions CREATE EXTENSION IF NOT EXISTS pg_stat_statements; CREATE EXTENSION IF NOT EXISTS pg_stat_kcache; CREATE EXTENSION IF NOT EXISTS pg_qualstats; CREATE EXTENSION IF NOT EXISTS pg_buffercache; -- Grant necessary permissions GRANT pg_monitor TO your_api_user; GRANT SELECT ON pg_stat_statements TO your_api_user; GRANT SELECT ON pg_stat_user_tables TO your_api_user; GRANT SELECT ON pg_stat_user_indexes TO your_api_user; GRANT SELECT ON pg_stat_database TO your_api_user; GRANT SELECT ON pg_stat_activity TO your_api_user; GRANT SELECT ON pg_locks TO your_api_user; GRANT SELECT ON pg_stat_replication TO your_api_user;
postgresql.conf Settings
Recommended PostgreSQL configuration for optimal monitoring
# postgresql.conf # Shared preload libraries shared_preload_libraries = 'pg_stat_statements' # pg_stat_statements configuration pg_stat_statements.max = 10000 pg_stat_statements.track = all pg_stat_statements.track_utility = on pg_stat_statements.track_planning = on # Logging configuration log_destination = 'stderr' logging_collector = on log_directory = 'log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_rotation_age = 1d log_rotation_size = 100MB log_min_duration_statement = 1000 # Log slow queries (1 second) # Statistics configuration track_activities = on track_counts = on track_io_timing = on track_functions = all # Connection settings max_connections = 100 shared_buffers = 256MB effective_cache_size = 1GB # WAL settings wal_level = replica max_wal_senders = 3 max_replication_slots = 3
Customization Options
Extend and customize pgSentinel for your needs
Custom Metrics
Add your own custom metrics to the monitoring system
You can add custom metrics by extending the Prometheus metrics in the backend:
Custom Dashboards
Create custom Grafana dashboards for specific use cases
Add custom dashboard JSON files to the monitoring/grafana/dashboards/ directory:
Alert Rules
Configure custom alert rules for your specific requirements
Modify the Prometheus alert rules in monitoring/prometheus/alerts.yml:
Configuration Validation
Verify your configuration is correct
Health Check
Verify all services are running correctly
Database Connection
Test PostgreSQL connectivity and permissions
Metrics Collection
Verify metrics are being collected and stored
Need Help?
If you're having trouble with configuration, check our troubleshooting guide or get support.