Production-ready MCP Server for intelligent Loki/Tempo observability dashboard analysis and generation
npm install observability-analyzerProduction-ready MCP Server for intelligent Loki log analysis and Grafana dashboard generation based on industry-standard monitoring methodologies (RED Method).
- Smart Analysis: Analyzes Loki logs to recommend optimal dashboard configurations
- RED Method Implementation: Industry-standard Rate, Errors, Duration monitoring dashboards
- Service Discovery: Automatic detection of services from log data
- Query Optimization: Performance optimization suggestions for LogQL queries
- Production Ready: Handles authentication, errors, and enterprise deployment scenarios
``bash`
npm install -g observability-dashboard-analyzer
The tool uses multi-tier configuration (environment variables > config file > defaults):
1. Environment Variables (highest priority):
`bash`
export LOKI_URL=http://localhost:3100
export LOKI_USERNAME=your-username
export LOKI_PASSWORD=your-password
2. Config File (medium priority):
Edit ~/.observability-analyzer/config.json:`
json`
{
"loki": {
"url": "http://localhost:3100",
"auth": {
"type": "basic",
"username": "your-username",
"password": "your-password"
}
}
}
Add to your Claude Desktop MCP configuration:
`json`
{
"mcpServers": {
"observability-analyzer": {
"command": "npx",
"args": ["observability-dashboard-analyzer"]
}
}
}
#### analyze_loki_stack
Analyzes your Loki setup and discovers services with log structure analysis.
`typescript`
// Example usage in Claude
"Analyze my Loki logs for the last 24 hours"
Returns:
- Service discovery from log data
- Log structure quality assessment
- Available labels and error patterns
- Dashboard recommendations based on data structure
#### generate_loki_dashboard
Creates production-ready Loki monitoring dashboard with service-specific panels.
`typescript`
"Generate a dashboard for my payment-api and user-service"
Features:
- Log volume monitoring by service
- Error rate tracking with thresholds
- Log level distribution analysis
- Service health overview
- Error pattern detection
#### validate_loki_queries
Tests LogQL queries against real Loki API to validate query performance.
`typescript`
"Validate these LogQL queries for performance"
Features:
- Query syntax validation
- Performance optimization suggestions
- Success rate analysis
- Query execution testing
#### export_loki_dashboard
Exports Loki dashboard to Grafana-compatible JSON file.
`typescript`
"Export dashboard for my services to a JSON file"
Features:
- Grafana-compatible JSON export
- Service-specific configurations
- Optimized LogQL queries
- Production-ready dashboard structure
The tool implements monitoring methodologies based on industry research:
- RED Method (Request rate, Error rate, Duration) - Universal microservices standard
- Service Discovery - Automatic detection from log labels and content
- Log Structure Analysis - Quality assessment for dashboard feasibility
Dashboards are recommended based on log data analysis:
- Service Discovery: Automatic detection from service labels and JSON content
- Log Structure Quality: Assessment of structured logs and error patterns
- Volume Analysis: Log throughput and service activity measurement
The tool provides performance optimization suggestions:
- LogQL Optimization: Avoid regex wildcards, use exact string matching first
- Label Filtering: Use specific label selectors for better performance
- Query Patterns: Efficient time-based and service-based queries
Supports authentication methods:
- Basic Auth: Username/password authentication (most common)
- No Auth: For local development setups
1. Log Volume Monitoring
- Service-based log volume tracking
- Request rate analysis from log data
- Time-based volume patterns
2. Error Rate Tracking
- Error detection from log patterns
- Industry-standard thresholds (1% yellow, 5% red)
- Error pattern analysis
3. Service Health Overview
- Multi-service comparison
- Log level distribution
- Service activity monitoring
Run the comprehensive test suite:
`bashRun all tests
npm test
Test Coverage:
- Unit tests for dashboard generators
- Integration tests with mocked Loki APIs
- Query validation and optimization testing
- Configuration and authentication testing
๐ Development
$3
`
src/
โโโ index.ts # MCP server entry point
โโโ config/
โ โโโ ConfigManager.ts # Multi-tier configuration
โ โโโ AuthHandler.ts # Authentication handling
โโโ analyzers/
โ โโโ LokiAnalyzer.ts # LogQL query generation & analysis
โโโ dashboards/
โ โโโ REDMethodGenerator.ts # RED method dashboards
โ โโโ GrafanaExporter.ts # Dashboard export utilities
โโโ types/
โ โโโ loki-api.ts # Loki API types
โ โโโ grafana-config.ts # Grafana dashboard types
โ โโโ monitoring-methods.ts # Monitoring methodology types
โ โโโ config.ts # Configuration types
โโโ __tests__/ # Test suite
`$3
`bash
npm run build # TypeScript compilation
npm run lint # ESLint checking
npm run typecheck # TypeScript type checking
`๐ Success Metrics
- Functional: Generates working dashboards for common Loki setups
- Performance: Analyzes Loki logs in <30 seconds
- Usability:
npm install -g โ working in Claude within 5 minutes
- Professional: 90%+ test coverage + comprehensive TypeScript types๐ค Contributing
1. Fork the repository
2. Create a feature branch:
git checkout -b feature/amazing-feature
3. Run tests: npm test
4. Commit changes: git commit -m 'Add amazing feature'
5. Push to branch: git push origin feature/amazing-feature`MIT License - see LICENSE file for details.
- RED Method Documentation
- Loki Documentation
- LogQL Documentation
---
Built for production observability teams who need immediate value from their Loki setup. ๐