Skip to content

Server log management is a critical task for organizations relying on web services, but it often presents challenges such as processing large volumes of data, identifying performance bottlenecks, and detecting security threats.

License

Notifications You must be signed in to change notification settings

akm323/server-log-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Server-log-analysis

Server log management is a critical task for organizations relying on web services, but it often presents challenges such as processing large volumes of data, identifying performance bottlenecks, and detecting security threats. Traditional approaches may be inefficient, lacking real-time updates or actionable insights. The proposed system addresses these issues by providing a real-time, web based solution for analyzing and visualizing server log data. Built using Flask, SQLAlchemy, Pandas, and Plotly, the system streamlines log analysis through intuitive dashboards and advanced visualizations. It identifies key metrics such as frequent IPs, request patterns, status code distributions, and device, allowing administrators to monitor server activity effectively. This system empowers users to quickly detect anomalies, optimize server performance, and enhance security by uncovering patterns and irregularities in the data. With user-friendly interfaces, it ensures that administrators have immediate access to critical insights, facilitating prompt and informed decision-making. By resolving the inefficiencies of traditional log management, the system is an essential tool for improving server reliability and operational efficiency. The system employs quantitative methodologies to derive insights from numeric and structured log data, presenting the results through intuitive visualizations and summary metrics. By combining robust data processing capabilities with interactive dashboards, this system is a comprehensive tool for server management and performance analysis, streamlining troubleshooting and decision-making processes.

How to run the system

Make sure to create the .env file and give a value to the SECRET_KEY in it. Then run the main.py and go to website link, now you have the system running.

Server Log Analysis System

A comprehensive real-time web application for analyzing and visualizing server log data. This system provides administrators with powerful tools to monitor server performance, detect anomalies, and gain insights into user behavior patterns.

πŸš€ Features

Real-time Log Processing

  • Live Data Extraction: Automatically processes new log entries from raw log files
  • Real-time Updates: WebSocket-based live updates to dashboards
  • File Monitoring: Watches log files for changes and processes them automatically

Interactive Dashboards

  • Overview Dashboard: Comprehensive metrics and visualizations
  • IP Tracking: Detailed analysis of specific IP addresses
  • URL Tracking: Analysis of specific request paths and endpoints
  • User Management: Admin interface for user account management

Analytics & Visualizations

  • Traffic Analysis: Request patterns over time, peak usage periods
  • Status Code Distribution: HTTP response code analysis with pie charts
  • Device Analysis: User agent parsing and device type distribution
  • Geographic Analysis: IP geolocation mapping (optional)
  • Performance Monitoring: Response time tracking and bottleneck identification

Security & User Management

  • User Authentication: Secure login system with password hashing
  • Session Management: Flask-Login integration for secure sessions
  • Admin Controls: User creation, deletion, and password management

πŸ› οΈ Technology Stack

  • Backend: Flask (Python web framework)
  • Database: SQLite with SQLAlchemy ORM
  • Data Processing: Pandas for data manipulation and analysis
  • Visualization: Plotly for interactive charts and graphs
  • Real-time: Flask-SocketIO for live updates
  • Authentication: Flask-Login for user management
  • File Monitoring: Watchdog for log file changes

πŸ“ Project Structure

server-log-analysis-main/
β”œβ”€β”€ ServerLogAnalysis/
β”‚   β”œβ”€β”€ app.py                 # Main Flask application
β”‚   β”œβ”€β”€ main.py               # Application entry point
β”‚   β”œβ”€β”€ config.py             # Configuration settings
β”‚   β”œβ”€β”€ data_queries.py       # Database query functions
β”‚   β”œβ”€β”€ Geolocation_Analysis.py # IP geolocation features
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ raw/              # Raw log files
β”‚   β”‚   β”œβ”€β”€ csv/              # Processed CSV data
β”‚   β”‚   └── processed/        # Analysis output files
β”‚   β”œβ”€β”€ templates/            # HTML templates
β”‚   β”‚   β”œβ”€β”€ index.html        # Main dashboard
β”‚   β”‚   β”œβ”€β”€ login.html        # Login page
β”‚   β”‚   β”œβ”€β”€ track_ip.html     # IP tracking page
β”‚   β”‚   └── track_url.html    # URL tracking page
β”‚   └── utils/
β”‚       β”œβ”€β”€ data_extractor.py # Log parsing and CSV conversion
β”‚       β”œβ”€β”€ SummaryAnalysis.py # Statistical analysis
β”‚       └── SetEnv.py         # Environment configuration
β”œβ”€β”€ requirements.txt          # Python dependencies
└── README.md

πŸš€ Quick Start

Prerequisites

  • Python 3.7 or higher
  • pip (Python package installer)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd server-log-analysis-main
  2. Install dependencies

    pip install -r requirements.txt
  3. Set up environment variables Create a .env file in the project root:

    SECRET_KEY=your-secret-key-here
  4. Prepare log data

    • Place your server log files in ServerLogAnalysis/data/raw/
    • The system expects Apache/Nginx style log format
  5. Run the application

    cd ServerLogAnalysis
    python main.py
  6. Access the dashboard

    • Open your browser and go to http://localhost:5000
    • Default admin credentials: username: ak, password: ak249

πŸ“Š Usage

Main Dashboard

  • View real-time server metrics and visualizations
  • Monitor request patterns, status codes, and device distributions
  • Access summary statistics and performance indicators

IP Tracking

  • Select specific IP addresses from the dropdown
  • Analyze request patterns, status codes, and device types for that IP
  • View time-series data for suspicious or high-activity IPs

URL Tracking

  • Track specific request paths and endpoints
  • Analyze which IPs are accessing particular resources
  • Monitor performance and error rates for specific URLs

User Management

  • Create new user accounts
  • Manage existing users
  • Change passwords securely

πŸ”§ Configuration

Database

The system uses SQLite by default. To use PostgreSQL:

  1. Update config.py with your database URI
  2. Install psycopg2 for PostgreSQL support

Log Format

The system expects logs in Apache/Nginx format:

IP - - [timestamp] "method path protocol" status size "user-agent" "referrer"

Customization

  • Modify data_extractor.py to support different log formats
  • Update visualization parameters in app.py
  • Customize HTML templates in the templates/ directory

πŸ“ˆ Analytics Features

Summary Statistics

  • Total requests and unique IP addresses
  • Status code distribution and most common responses
  • Average response times and performance metrics

Traffic Analysis

  • Hourly and daily request patterns
  • Peak usage identification
  • Geographic distribution (with geolocation enabled)

Security Monitoring

  • Suspicious IP detection
  • Error rate monitoring
  • User agent analysis for bot detection

πŸ›‘οΈ Security Features

  • Password hashing with Werkzeug
  • Session-based authentication
  • CSRF protection
  • Input validation and sanitization

πŸ“ API Endpoints

  • GET / - Main dashboard
  • GET /login - Login page
  • POST /login - Authentication
  • GET /track_ip - IP tracking interface
  • POST /track_ip - IP analysis data
  • GET /track_url - URL tracking interface
  • POST /track_url - URL analysis data
  • GET /manage_users - User management
  • POST /signup - User registration
  • POST /change_password - Password change

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

For issues and questions:

  1. Check the project documentation
  2. Review existing issues
  3. Create a new issue with detailed description

πŸ”„ Updates

The system automatically:

  • Monitors log files for new entries
  • Updates the database with new data
  • Refreshes visualizations in real-time
  • Maintains data integrity and consistency

About

Server log management is a critical task for organizations relying on web services, but it often presents challenges such as processing large volumes of data, identifying performance bottlenecks, and detecting security threats.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published