{"id":15043539,"url":"https://github.com/kovvalveetil/web-traffic-anomaly-detector","last_synced_at":"2025-07-24T11:34:43.897Z","repository":{"id":256631023,"uuid":"855406012","full_name":"KovvalVeetil/web-traffic-anomaly-detector","owner":"KovvalVeetil","description":"The Web Traffic Anomaly Detector is a Ruby on Rails application designed to monitor web traffic logs and detect anomalies such as high traffic from a single IP address or unusual request patterns. The project aims to help identify potential issues like bot attacks, unauthorized access, or other irregular activities in web server traffic. WIP","archived":false,"fork":false,"pushed_at":"2024-09-29T19:33:43.000Z","size":56377,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T23:12:15.045Z","etag":null,"topics":["apache","postgresql","redis","ruby","ruby-on-rails","scripts","sidekiq"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KovvalVeetil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-10T20:15:34.000Z","updated_at":"2025-02-07T16:14:40.000Z","dependencies_parsed_at":"2024-09-12T05:50:26.252Z","dependency_job_id":null,"html_url":"https://github.com/KovvalVeetil/web-traffic-anomaly-detector","commit_stats":null,"previous_names":["kovvalveetil/web-traffic-anomaly-detector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KovvalVeetil%2Fweb-traffic-anomaly-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KovvalVeetil%2Fweb-traffic-anomaly-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KovvalVeetil%2Fweb-traffic-anomaly-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KovvalVeetil%2Fweb-traffic-anomaly-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KovvalVeetil","download_url":"https://codeload.github.com/KovvalVeetil/web-traffic-anomaly-detector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975329,"owners_count":21192210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","postgresql","redis","ruby","ruby-on-rails","scripts","sidekiq"],"created_at":"2024-09-24T20:49:14.467Z","updated_at":"2025-04-14T23:12:30.605Z","avatar_url":"https://github.com/KovvalVeetil.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web Traffic Anomaly Detector - Backend\n\nThe Web Traffic Anomaly Detector is a Ruby on Rails application designed to monitor web traffic logs and detect anomalies such as high traffic from a single IP address or unusual request patterns. The project aims to help identify potential issues like bot attacks, unauthorized access, or other irregular activities in web server traffic.\n\n## Features\n\n- **Log Monitoring:** Collect and store web server logs (e.g., Apache, Nginx) in a PostgreSQL database.\n- **Anomaly Detection:** Identify anomalies such as sudden traffic spikes, repetitive requests, or suspicious IP addresses using simple rules-based logic.\n- **Alerts and Reports:** Notify users when anomalies are detected and provide basic reports on detected anomalies.\n- **Background Processing:** Utilize background jobs with Sidekiq or Rails' built-in Active Job for asynchronous log processing.\n- **User Interface:** A simple web UI to display logs, detected anomalies, and basic traffic visualizations using Chartkick or D3.js.\n\n## Technologies Used\n\n- **Backend:** Ruby on Rails\n- **Database:** PostgreSQL\n- **Background Jobs:** Sidekiq or Rails Active Job\n- **Log Parsing:** Logstash or custom Ruby scripts\n- **Data Visualization:** Chartkick or D3.js\n- **Web Server:** Apache or Nginx (for generating logs)\n\n## Getting Started\n\n### Prerequisites\n\n- Ruby (version 3.0 or above)\n- Rails (version 7.0 or above)\n- PostgreSQL (version 13 or above)\n- Redis (if using Sidekiq for background jobs)\n- Apache or Nginx (for log generation)\n\n### Installation\n\n1. **Clone the Repository:**\n\n    ```bash\n    git clone https://github.com/your-username/web-traffic-anomaly-detector.git\n    cd web-traffic-anomaly-detector\n    ```\n\n2. **Install Dependencies:**\n\n    ```bash\n    bundle install\n    ```\n\n3. **Set Up Database:**\n\n    Create and migrate the database:\n\n    ```bash\n    rails db:create\n    rails db:migrate\n    ```\n\n4. **Configure Web Server:**\n\n    Set up Apache or Nginx on your local machine to generate logs. Ensure logs are accessible by your Rails application for ingestion.\n\n5. **Start the Rails Server:**\n\n    ```bash\n    rails server\n    ```\n\n### Running Background Jobs\n\nSetup Redis, Sidekiq\n\n\n\n```bash\nsudo apt update\nsudo apt install redis-server\n\nsudo systemctl start redis-server\n\nsudo systemctl status redis-server\n\ngem 'sidekiq'\nbundle exec sidekiq\n```\n\n### Configuration\n\n```bash\nconfig/initializers/sidekiq.rb\nconfig/application.rb\n```\n\n### Set Up Apache Web Server\n- Create an Apache configuration file for the web server. Save this as web_server_test.conf in /etc/apache2/sites-available/\n\n```bash\nsudo a2ensite web_server_test.conf\nsudo systemctl reload apache2\n```\n\n- Create a sample HTML file for testing in /path/to/your/workspace/web_server_test/html/index.html\n\n- Create Log Parsing Script\nCreate a log parsing script in lib/log_parsers/parse_logs.rb:\n\n### Setup background jobs with sidekiq\n\n```bash\nrails generate job AnomalyDetection\n\nbundle exec sidekiq\n\n```\n\n### Alerts and Notifications\n- Create Mailer\n\n```bash\nrails generate mailer AnomalyMailer\n```\n- Configure Email Settings\n```bash\nconfig/environments/development.rb\n```\n- Develop Alert Templates\n```bash\napp/views/anomaly_mailer/anomaly_alert.html.erb\n```\n- Integrate Alerts with Detection\n```bash\napp/services/anomaly_detector.rb\n```\n- Testing\n```bash\nanomaly = Anomaly.first\nAnomalyMailer.anomaly_alert(anomaly).deliver_now\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovvalveetil%2Fweb-traffic-anomaly-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkovvalveetil%2Fweb-traffic-anomaly-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovvalveetil%2Fweb-traffic-anomaly-detector/lists"}