A modern web-based management interface for Prometheus that extends its capabilities with metric-specific retention policies and AI-powered query generation.
Prometric addresses key limitations in Prometheus monitoring by providing:
- Granular Retention Control: Set different retention periods per metric instead of global retention
- Natural Language Queries: Convert plain English questions into PromQL using AI
- Unified Management Interface: Complete web dashboard for all Prometheus operations
- Unified Dashboard: Complete web interface for Prometheus monitoring
- Metric-Specific Retention: Configure different retention periods per metric
- AI-Powered Query Assistant: Natural language to PromQL translation
- Advanced Graphing: Interactive charts and visualizations
- Target Management: Monitor scrape targets and their status
- Alert Management: View and manage Prometheus alerts
- Query Interface: Execute PromQL queries with syntax highlighting
- System Status: Real-time system health and performance metrics
- Natural Language Processing: Ask questions like "What is my memory usage?"
- Smart Metric Selection: Automatically selects appropriate metrics from your Prometheus instance
- Interactive Chat Interface: Chat with the AI directly in the Query tab
- Query Suggestions: Get AI-powered PromQL query recommendations
- Seamless Integration: Generated queries can be directly used in the PromQL input
- Flexible Retention Policies: Set retention periods per metric pattern (supports fractional days)
- Regex Pattern Matching: Use wildcards and regex for metric selection
- Automated Execution: Background scheduler runs retention policies automatically
- Dry Run Testing: Test policies without actually deleting data
- Execution Logging: Track policy execution history and results
- Real-time Monitoring: Monitor retention policy effectiveness
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend │ │ Prometheus │
│ (Next.js) │◄──►│ (FastAPI) │◄──►│ Server │
│ │ │ │ │ │
│ • Query Tab │ │ • API Proxy │ │ • Metrics │
│ • Graph Tab │ │ • AI Service │ │ • Alerts │
│ • Alerts Tab │ │ • Retention │ │ • Targets │
│ • Targets Tab │ │ • Scheduler │ │ • TSDB │
│ • Retention Tab │ │ │ │ │
│ • Status Tab │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌──────────────────┐
│ Database │
│ (SQLite) │
│ │
│ • Policies │
│ • Execution Logs │
└──────────────────┘
- Python 3.8+
- Node.js 18+
- Running Prometheus instance
- OpenAI API key (optional, for AI features)
-
Install dependencies
cd src pip install -r requirements.txt -
Configure environment
export PROMETHEUS_URL="http://localhost:9090" export OPENAI_API_KEY="sk-your-key-here" # Optional export DATABASE_URL="sqlite:///./data/prometheus_retention.db"
-
Start backend server
python main.py
-
Install dependencies
cd frontend npm install -
Start development server
npm run dev
-
Access application
- Web interface:
http://localhost:3000 - API documentation:
http://localhost:8000/docs
- Web interface:
For detailed instructions on configuring and using the AI-powered features, please see AI_SETUP.md.
- Enter PromQL queries directly
- View results in table or JSON format
- Copy queries to clipboard
- Query history and suggestions
- Click the AI Assistant button
- Ask natural language questions:
- "What is my memory usage?"
- "Show me CPU utilization"
- "How much disk space is available?"
- "What's the network traffic like?"
- "Is my system running properly?"
The AI will:
- Translate your question to PromQL
- Explain why it chose specific metrics
- Show which metrics were used
- Provide buttons to use or copy the query
- Execute PromQL queries with time-series visualization
- Interactive charts with zoom and pan
- Multiple time range options
- Export graph data
- View active and firing alerts
- Alert status and labels
- Alert history and annotations
- Monitor scrape targets
- Target health and last scrape time
- Endpoint status and error messages
- Create and manage retention policies
- Test policies with dry runs
- View execution history and logs
- Monitor policy effectiveness
- System health monitoring
- Prometheus configuration
- TSDB statistics
- Runtime information
- Navigate to Retention Tab
- Click "Create New Policy"
- Configure the policy:
- Metric Pattern: Use wildcards (
cpu_*) or regex (^node_.*) - Retention Period: Days to keep data (supports fractional days)
- Description: Optional description
- Enabled: Enable/disable the policy
- Metric Pattern: Use wildcards (
// Keep memory metrics for 7 days
Pattern: "node_memory_*"
Retention: 7.0 days
// Keep probe metrics for 1 hour
Pattern: "probe_*"
Retention: 0.042 days // 1 hour = 1/24 days
// Keep all Go runtime metrics for 1 week
Pattern: "go_*"
Retention: 7.0 days| Duration | Days Value | Example Usage |
|---|---|---|
| 1 minute | 0.0007 | 0.0007 |
| 5 minutes | 0.0035 | 0.0035 |
| 1 hour | 0.0417 | 0.0417 |
| 6 hours | 0.25 | 0.25 |
| 1 day | 1.0 | 1.0 |
| 1 week | 7.0 | 7.0 |
| 1 month | 30.0 | 30.0 |
Use Dry Run to test policies without deleting data:
- Shows metrics that would be affected
- Displays time ranges for deletion
- Validates policy configuration
- Safe testing environment
Policies are executed automatically every 6 hours (configurable via RETENTION_CHECK_INTERVAL_HOURS).
Manual execution is also available:
- Execute individual policies
- Execute all policies at once
- View execution logs and results
Make sure you have Docker and Docker Compose installed.
docker-compose up -d| Variable | Default | Description |
|---|---|---|
PROMETHEUS_URL |
http://localhost:9090 |
Prometheus server URL |
OPENAI_API_KEY |
- | OpenAI API key for AI features |
DATABASE_URL |
sqlite:///./data/prometheus_retention.db |
Database connection string |
RETENTION_CHECK_INTERVAL_HOURS |
6 |
Retention policy execution interval |
API_HOST |
0.0.0.0 |
Backend API host |
API_PORT |
8000 |
Backend API port |
LOG_LEVEL |
INFO |
Logging level |
LOG_FILE |
./logs/app.log |
Log file path |
The application uses SQLite by default, but supports PostgreSQL and MySQL:
# PostgreSQL
export DATABASE_URL="postgresql://user:password@localhost/prometheus_retention"
# MySQL
export DATABASE_URL="mysql://user:password@localhost/prometheus_retention"
# SQLite (default)
export DATABASE_URL="sqlite:///./data/prometheus_retention.db"Retention Service: Manages metric lifecycle policies
- Pattern matching for metric selection
- Automated data cleanup based on age
- Execution logging and monitoring
AI Service: Provides natural language processing
- OpenAI GPT integration for query translation
- Context-aware metric selection
- Query suggestion generation
Scheduler: Handles background operations
- Periodic retention policy execution
- Configurable execution intervals
- Error handling and recovery
# Backend tests
cd src
python -m pytest tests/
# Frontend tests
cd frontend
npm testFor more details about the available test utilities and usage, see the tests/README.md
GET/POST /api/v1/*- Proxy to Prometheus APIPOST /prometheus-proxy/query- Execute PromQL queriesGET /prometheus-proxy/metrics- Get available metricsGET /prometheus-proxy/targets- Get scrape targetsGET /prometheus-proxy/alerts- Get alerts
GET /retention-policies- List all policiesPOST /retention-policies- Create policyPUT /retention-policies/{id}- Update policyDELETE /retention-policies/{id}- Delete policyPOST /retention-policies/{id}/execute- Execute policyPOST /retention-policies/{id}/dry-run- Test policy
POST /ai/translate- Translate natural language to PromQLPOST /ai/suggestions- Get AI-powered suggestionsGET /ai/status- Check AI service status
GET /health- Health checkGET /system-info- System informationGET /config- Current configuration
Full API documentation available at /docs when running the backend.
- Problem: "OpenAI API not configured" message
- Solution:
- Verify
OPENAI_API_KEYenvironment variable is set - Check API key validity at OpenAI platform
- Restart the backend server
- Check backend logs for detailed errors
- Verify
- Problem: Cannot connect to Prometheus
- Solution:
- Verify
PROMETHEUS_URLis correct - Check Prometheus is running and accessible
- Ensure admin API is enabled:
--web.enable-admin-api - Check firewall and network connectivity
- Verify
- Problem: Policies created but data not being deleted
- Solution:
- Check policy is enabled
- Use dry run to test policy
- Verify metric patterns match existing metrics
- Check execution logs for errors
- Ensure Prometheus admin API is enabled
- Problem: npm build failures
- Solution:
- Clear node_modules:
rm -rf node_modules && npm install - Clear Next.js cache:
rm -rf .next - Check Node.js version compatibility
- Review console errors for specific issues
- Clear node_modules:
- Monitor retention policy frequency
- Adjust
RETENTION_CHECK_INTERVAL_HOURS - Consider using PostgreSQL for large deployments
- Monitor Prometheus TSDB size
- Use more specific metric patterns
- Reduce query time ranges
- Consider Prometheus query optimization
- Monitor system resources
- API Keys: Never commit API keys to version control
- Database: Use proper database security in production
- Network: Configure appropriate firewall rules
- Authentication: Consider adding authentication for production use
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Set up both frontend and backend development environments
- Use the testing utilities in
tests/for validation - Follow the existing code style and patterns
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Prometheus - The monitoring system that powers this project
- OpenAI - For AI-powered query translation
- FastAPI - Modern Python web framework
- Next.js - React framework for the frontend
- Tailwind CSS - Utility-first CSS framework
Prometric provides enterprise-grade retention management and AI-enhanced query capabilities for Prometheus monitoring infrastructure.
Project Specification- https://docs.google.com/document/d/10NjgoF0igdcuzyo_auq6zg1NrObEWZvweCbSV-8CZhQ/edit?usp=sharing