Enhance log analysis with advanced filtering and search capabilities

Add comprehensive log analysis features to improve troubleshooting workflows:
- Time-based filtering (8pm-6am shifts) with HH:MM format support
- Multi-level log filtering (ERROR, WARNING, EMERGENCY, etc.)
- Full-text search across log content with case-insensitive matching
- Proper line break formatting for readable output
- Line count limiting for large log files

New REST API endpoints:
- /api/logs/errors/{job_id} - Get only error/warning logs
- /api/logs/search/{job_id} - Search logs for specific terms
- Enhanced /api/logs/job/{job_id} with filtering parameters

New MCP tools:
- get_error_logs - Streamlined error analysis
- search_job_logs - Pattern-based log searching
- Enhanced get_job_logs with all filtering options

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-06-02 17:42:35 +07:00
parent 3aa1d90b89
commit dc2fe4c425
3 changed files with 489 additions and 44 deletions

View File

@ -26,6 +26,42 @@ Nomad MCP is a service that enables management of HashiCorp Nomad jobs via REST
Always maintain backward compatibility with existing API endpoints. Follow REST principles.
## Enhanced Log Analysis Features
The logs API has been enhanced with advanced filtering and analysis capabilities:
### REST API Endpoints:
- `/api/logs/job/{job_id}` - Enhanced with time, level, and search filtering
- `/api/logs/errors/{job_id}` - Get only error/warning logs
- `/api/logs/search/{job_id}` - Search logs for specific terms
- `/api/logs/repository/{repository}` - Get logs by repository name
### New Query Parameters:
- `start_time` & `end_time` - Filter by time range (HH:MM format)
- `log_level` - Filter by levels (ERROR, WARNING, INFO, etc.)
- `search` - Search for specific terms
- `lines` - Limit number of lines returned
- `formatted` - Proper line breaks (default: true)
### MCP Tools Available:
- `get_job_logs` - Enhanced with all filtering options
- `get_error_logs` - Convenience tool for troubleshooting
- `search_job_logs` - Search logs for patterns
### Example Usage:
```bash
# Get errors between 8pm-6am for plant-manager in production
curl "https://nomad_mcp.dev.meisheng.group/api/logs/errors/plant-manager?namespace=production&start_time=20:00&end_time=06:00"
# Search for pump issues
curl "https://nomad_mcp.dev.meisheng.group/api/logs/search/plant-manager?q=pump&namespace=production"
# Get last 50 lines with proper formatting
curl "https://nomad_mcp.dev.meisheng.group/api/logs/job/plant-manager?namespace=production&lines=50&formatted=true"
```
Always maintain backward compatibility with existing API endpoints. Follow REST principles.
## SSL Certificate Management for Internal Services
When working with internal/corporate services that use custom Certificate Authorities (CAs):