Enterprise-Grade Log Analysis & Reporting Solution
A high-performance, production-ready log analysis platform built with Go, designed for enterprise environments requiring robust log processing, real-time analytics, and comprehensive reporting capabilities.
- Overview
- Key Features
- Architecture
- Quick Start
- Installation
- Configuration
- API Reference
- Usage Examples
- Deployment
- Development
- Contributing
- Support
The Go-Based Server Log Analyzer & Reporting Platform is a comprehensive solution for organizations that need to process, analyze, and report on large volumes of server logs. Built with Go's performance characteristics and enterprise-grade design patterns, it provides:
- Multi-format log support (Apache, Nginx, Generic)
- Real-time processing with concurrent worker pools
- Advanced analytics and statistical reporting
- Automated scheduling and alerting
- Scalable architecture for high-throughput environments
- Multi-Format Log Processing: Native support for Apache, Nginx, and generic log formats
- Real-Time Analytics: Live processing with immediate insights and statistics
- Enterprise Reporting: Professional HTML and CSV reports with customizable templates
- Automated Scheduling: Built-in cron jobs for daily, weekly, and monthly reports
- Database Integration: Optimized MySQL/PostgreSQL support with connection pooling
- Concurrent Processing: Go goroutines for parallel log ingestion and analysis
- Memory Optimization: Efficient memory management with Go's garbage collector
- Database Performance: Indexed queries and prepared statements for optimal performance
- Scalable Architecture: Designed to handle millions of log entries efficiently
- Security: Input validation, SQL injection protection, and secure headers
- Monitoring: Comprehensive health checks, metrics, and observability
- Reliability: ACID-compliant transactions and error handling
- Extensibility: Modular design for easy customization and extension
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Web Interface Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β API Gateway Layer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Business Logic Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β Log Process β β Reporting β β Alerting & β β
β β Engine β β Engine β β Scheduling β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Data Access Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β MySQL β β PostgreSQL β β Cache Layer β β
β β Database β β Database β β (Redis) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Component | Technology | Version | Purpose |
---|---|---|---|
Runtime | Go (Golang) | 1.21+ | High-performance backend execution |
Web Framework | Gorilla Mux | Latest | HTTP routing and middleware |
Database | MySQL/PostgreSQL | 8.0+/13+ | Persistent data storage |
Templates | Go HTML Templates | Built-in | Dynamic report generation |
Scheduling | robfig/cron | v3 | Automated task execution |
Logging | Logrus | Latest | Structured application logging |
Configuration | Viper | Latest | Flexible configuration management |
- Go: 1.21 or higher
- Database: MySQL 8.0+ or PostgreSQL 13+
- Git: For version control
- Docker: For containerized deployment (optional)
git clone [email protected]:ShashankBejjanki1241/Go-Based-Server-Log-Analyzer-Reporting-Platform.git
cd Go-Based-Server-Log-Analyzer-Reporting-Platform
go mod download
# Copy configuration template
cp config.yaml config.local.yaml
# Edit with your database credentials
nano config.local.yaml
# Build application
go build -o bin/log-analyzer cmd/server/main.go
# Run with local configuration
./bin/log-analyzer -config config.local.yaml
Open your browser and navigate to: http://localhost:8080
# Clone repository
git clone [email protected]:ShashankBejjanki1241/Go-Based-Server-Log-Analyzer-Reporting-Platform.git
cd Go-Based-Server-Log-Analyzer-Reporting-Platform
# Install dependencies
go mod download
# Build application
make build
# Run application
make run
# Build Docker image
docker build -t log-analyzer .
# Run with Docker Compose
docker-compose up -d
CREATE DATABASE log_analyzer CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'loguser'@'%' IDENTIFIED BY 'logpass';
GRANT ALL PRIVILEGES ON log_analyzer.* TO 'loguser'@'%';
FLUSH PRIVILEGES;
CREATE DATABASE log_analyzer;
CREATE USER loguser WITH PASSWORD 'logpass';
GRANT ALL PRIVILEGES ON DATABASE log_analyzer TO loguser;
server:
port: "8080"
host: "localhost"
read_timeout: 30
write_timeout: 30
database:
type: "mysql" # or "postgres"
host: "localhost"
port: 3306
username: "loguser"
password: "logpass"
database: "log_analyzer"
ssl_mode: "disable"
logging:
level: "info"
output_file: "logs/app.log"
max_size: 100
max_backups: 3
Variable | Default | Description |
---|---|---|
LOG_ANALYZER_PORT |
8080 | Server port |
LOG_ANALYZER_DB_HOST |
localhost | Database host |
LOG_ANALYZER_DB_TYPE |
mysql | Database type |
LOG_ANALYZER_LOG_LEVEL |
info | Logging level |
http://localhost:8080
Currently, the API operates without authentication. For production use, implement appropriate authentication mechanisms.
GET /health
Returns system health status and database connectivity information.
POST /api/v1/logs/upload
Content-Type: multipart/form-data
Parameters:
- logfile: Log file to upload
- log_type: "apache", "nginx", or "generic"
GET /api/v1/logs?limit=100&offset=0&log_type=apache&status_code=200&source_ip=192.168.1.100
Query Parameters:
- limit: Maximum number of logs to return (default: 100)
- offset: Number of logs to skip (default: 0)
- log_type: Filter by log type
- status_code: Filter by HTTP status code
- source_ip: Filter by source IP address
- path: Filter by request path
- method: Filter by HTTP method
GET /api/v1/logs/stats
Returns comprehensive log processing and database statistics.
POST /api/v1/reports/generate
Content-Type: application/json
{
"report_name": "daily_analysis",
"log_type": "apache",
"format": "both",
"filters": {
"start_time": "2023-10-10T00:00:00Z",
"end_time": "2023-10-10T23:59:59Z"
}
}
GET /api/v1/reports # List available reports
GET /api/v1/reports/{filename} # Download specific report
All API responses follow a consistent JSON format:
{
"status": "success",
"data": { ... },
"message": "Operation completed successfully",
"timestamp": "2023-10-10T13:55:36Z"
}
curl -X POST http://localhost:8080/api/v1/logs/upload \
-F "logfile=@/var/log/apache2/access.log" \
-F "log_type=apache"
curl -X POST http://localhost:8080/api/v1/logs/upload \
-F "logfile=@/var/log/nginx/access.log" \
-F "log_type=nginx"
curl -X POST http://localhost:8080/api/v1/logs/upload \
-F "logfile=@/var/log/app/application.log" \
-F "log_type=generic"
# Get last 50 logs
curl "http://localhost:8080/api/v1/logs?limit=50"
# Get logs from specific time range
curl "http://localhost:8080/api/v1/logs?start_time=2023-10-10T00:00:00Z&end_time=2023-10-10T23:59:59Z"
# Get all error logs
curl "http://localhost:8080/api/v1/logs?status_code=500&limit=100"
# Get successful requests
curl "http://localhost:8080/api/v1/logs?status_code=200&limit=100"
# Get logs from specific IP
curl "http://localhost:8080/api/v1/logs?source_ip=192.168.1.100"
# Get logs for specific path
curl "http://localhost:8080/api/v1/logs?path=/api/users"
curl -X POST http://localhost:8080/api/v1/reports/generate \
-H "Content-Type: application/json" \
-d '{
"report_name": "daily_summary_$(date +%Y-%m-%d)",
"format": "both",
"filters": {
"start_time": "$(date -d 'yesterday' -u +%Y-%m-%dT00:00:00Z)",
"end_time": "$(date -d 'yesterday' -u +%Y-%m-%dT23:59:59Z)"
}
}'
curl -X POST http://localhost:8080/api/v1/reports/generate \
-H "Content-Type: application/json" \
-d '{
"report_name": "error_analysis",
"log_type": "apache",
"format": "html",
"filters": {
"status_code": [400, 401, 403, 404, 500, 502, 503, 504],
"start_time": "2023-10-01T00:00:00Z",
"end_time": "2023-10-31T23:59:59Z"
}
}'
# Set production environment variables
export LOG_ANALYZER_ENV=production
export LOG_ANALYZER_DB_HOST=your-db-host
export LOG_ANALYZER_DB_PASSWORD=your-secure-password
# Build with optimizations
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o log-analyzer cmd/server/main.go
# Create production package
tar -czf log-analyzer-production.tar.gz log-analyzer config.yaml
# Copy to production server
scp log-analyzer-production.tar.gz user@your-server:/opt/log-analyzer/
# Extract and setup
ssh user@your-server
cd /opt/log-analyzer
tar -xzf log-analyzer-production.tar.gz
chmod +x log-analyzer
[Unit]
Description=Log Analyzer Service
After=network.target mysql.service
[Service]
Type=simple
User=loguser
WorkingDirectory=/opt/log-analyzer
ExecStart=/opt/log-analyzer/log-analyzer
Restart=always
RestartSec=5
Environment=LOG_ANALYZER_ENV=production
[Install]
WantedBy=multi-user.target
version: '3.8'
services:
log-analyzer:
build: .
ports:
- "8080:8080"
environment:
- LOG_ANALYZER_ENV=production
depends_on:
- mysql
restart: unless-stopped
apiVersion: apps/v1
kind: Deployment
metadata:
name: log-analyzer
spec:
replicas: 3
selector:
matchLabels:
app: log-analyzer
template:
metadata:
labels:
app: log-analyzer
spec:
containers:
- name: log-analyzer
image: log-analyzer:latest
ports:
- containerPort: 8080
env:
- name: LOG_ANALYZER_ENV
value: "production"
# Clone repository
git clone [email protected]:ShashankBejjanki1241/Go-Based-Server-Log-Analyzer-Reporting-Platform.git
cd Go-Based-Server-Log-Analyzer-Reporting-Platform
# Install development dependencies
go mod download
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Setup pre-commit hooks
cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific package tests
go test ./pkg/logprocessor
# Run benchmarks
go test -bench=. ./pkg/logprocessor
# Run linter
golangci-lint run
# Format code
go fmt ./...
# Vet code
go vet ./...
βββ cmd/
β βββ server/
β βββ main.go # Application entry point
βββ pkg/
β βββ config/ # Configuration management
β βββ database/ # Database operations
β βββ logprocessor/ # Log parsing engine
β βββ models/ # Data models
β βββ reporting/ # Report generation
βββ web/
β βββ templates/ # HTML templates
βββ testdata/ # Test data files
βββ config.yaml # Configuration
βββ docker-compose.yml # Docker setup
βββ Dockerfile # Container definition
βββ Makefile # Build automation
βββ README.md # This file
We welcome contributions from the community! Please follow these guidelines:
- 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
- Follow Go coding standards and conventions
- Write comprehensive tests for new features
- Update documentation for API changes
- Ensure all tests pass before submitting PR
- Use conventional commit messages
- Use
gofmt
for code formatting - Follow Go naming conventions
- Write clear, descriptive comments
- Keep functions focused and concise
- Use meaningful variable names
Metric | Value | Description |
---|---|---|
Log Processing | 10,000+ entries/sec | Throughput for log ingestion |
Database Queries | 1,000+ queries/sec | Database operation performance |
Report Generation | < 2 seconds | HTML report generation time |
Memory Usage | < 100MB | Typical memory consumption |
Concurrent Users | 100+ | Simultaneous connection support |
- Horizontal Scaling: Stateless design for easy replication
- Load Balancing: Ready for load balancer integration
- Database Sharding: Support for database distribution
- Caching: Redis integration for performance optimization
- Input Validation: Comprehensive input sanitization
- SQL Injection Protection: Prepared statements usage
- CORS Configuration: Configurable cross-origin policies
- Rate Limiting: Built-in request throttling
- Secure Headers: Security-focused HTTP headers
- Use HTTPS in production environments
- Implement proper authentication and authorization
- Regular security updates and dependency management
- Monitor and log security events
- Follow OWASP security guidelines
# Application health
curl http://localhost:8080/health
# Database connectivity
curl http://localhost:8080/health | jq '.database_status'
- Structured Logging: JSON-formatted logs with context
- Performance Metrics: Request/response timing and statistics
- Error Tracking: Comprehensive error logging and reporting
- Database Monitoring: Query performance and connection health
- Threshold-based Alerts: Configurable alerting rules
- Email Notifications: Automated alert delivery
- Integration Support: Webhook and API integrations
- Escalation Policies: Multi-level alert escalation
- Real-time Streaming: WebSocket support for live log monitoring
- Advanced Analytics: Machine learning-based anomaly detection
- Enhanced Alerting: Email, Slack, and PagerDuty integrations
- Kubernetes Native: Helm charts and operator support
- Metrics Integration: Prometheus and Grafana support
- GraphQL API: Modern API query language support
- Multi-tenancy: Enterprise multi-tenant architecture
- Advanced Search: Elasticsearch integration for complex queries
- Global Distribution: Multi-region deployment support
- AI-Powered Insights: Predictive analytics and recommendations
- Compliance Features: GDPR, SOC2, and industry compliance
- Enterprise Integration: SSO, LDAP, and enterprise tools
- Mobile Applications: Native mobile apps for monitoring
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 ShashankBejjanki1241
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Documentation: Comprehensive guides and examples
- Issues: Report bugs and request features via GitHub Issues
- Discussions: Community support and Q&A
- Examples: Code samples and use case demonstrations
- GitHub Repository: Project Homepage
- Issues: Bug Reports & Feature Requests
- Discussions: Community Q&A
For enterprise support and consulting services, please contact the development team.