Skip to main content

ELB Log Analyzer

Tool for analyzing ELB logs for automating steps to retreive details of ip's user agent, total request count, to which urls requests were made along with their total count, and http methods in json format.

S3 Bucket Log Downloader

Downloads S3 bucket objects that we created in specified time window.

Installation

  • Using Pip

    python3 -m pip install elb-log-analyzer
    

AWS configuration

  • Create IAM policy with below configuration

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "S3ListSpecificDirectory",
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::alb-log-bucket-name"
        },
        {
            "Sid": "S3GetSpecificDirectory",
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/*"
        }
    ]
    }
    

    Note: above policy will allow user to list all contents in the bucket but download objects only from s3://alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/*

  • Create AWS access keys

  • Use aws cli to configure access key for boto3

    aws configure
    

S3 Bucket Log Downloader Usage

  • Print Help Menu.

    python3 -m elb_log_analyzer.s3_log -h
    
  • Download all log files generated in 10 hours from now.

    python3 -m elb_log_analyzer.s3_log -b elb-log-bucket -p 'alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/' -H 10
    
  • Download all log files generated in 40 mins from now.

    python3 -m elb_log_analyzer.s3_log -b elb-log-bucket -p 'alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/' -m 40
    
  • Download all log files generated in 20 secs from now.

    python3 -m elb_log_analyzer.s3_log -b elb-log-bucket -p 'alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/' -s 20
    
  • Download all log files generated in 10 hours, 40 mins and 20 secs from now and store in a directory.

    python3 -m elb_log_analyzer.s3_log -b elb-log-bucket -p 'alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/' --hours 10 --minutes 40 --seconds 20 -o './logs/downloads'
    

Analyzer

Analyzes downloaded log files.

Analyzer Usage

  • Print Help Menu

    python3 -m elb_log_analyzer -h
    
  • Print json data on console

    python3 -m elb_log_analyzer -i [INPUT_LOG_FILE_PATH]
    
  • Store json data in a file

    python3 -m elb_log_analyzer -i [INPUT_LOG_FILE_PATH] -o [OUTPUT_FILE_PATH]
    

    Note: INPUT_LOG_FILE_PATH can be log file or a directory containing all log files ending with .log extension

  • Get IP details from IPAbuseDB

    python3 -m elb_log_analyzer -i [LOG_FILE_PATH] -t [REQUESTS_THRESHOLD_VALUE] -k [IP_ABUSE_DB_API_KEY] -o [OUTPUT_FILE_PATH]
    

Alerts

Send alert to slack channel with abusive ip details.

Usage

  • Send alert from analyzed file

    python elb_log_analyzer.alerts -w [SLACK_WEBHOOK] -f [ANALYZED_LOG_FILE_LOCATION]
    

Dashboard

Dashboard to visualize data.

Dashboard Installation

  • Install requirements

    python3 -m pip install dashboard/requirements.txt
    

Usage

  • Start App

    streamlit run dashboard/app.py
    
  • Enter Log File/Directory Path

Publish package to pypi

  • Using poetry

    python3 -m poetry publish --build --username [PYPI_USERNAME] --password [PYPI_PASSWORD]
    

Usage Summary

  • Download log files

    python3 -m elb_log_analyzer.s3_log -b elb-log-bucket -p 'alb-log-bucket-name/AWSLogs/XXXXXXXXXXXX/elasticloadbalancing/aws-region/' -H [HOURS] -o logs
    
  • Analyze Log Files

    python3 -m elb_log_analyzer -i logs -o log.json -t [REQUEST_THRESHOLD] -k [IP_ABUSE_API_KEY] 
    
  • Send Alert to slack with client ips having total number of requests greater than threshold requests

    python -m elb_log_analyzer.alerts -w [SLACK_WEBHOOK] -f [ANALYZED_LOG_FILE_LOCATION]
    
  • Visualize Analyzed Logs using Dashboard

    streamlit run dashboard/app.py
    

Docker

  • Pull image

    docker pull dmdhrumilmistry/elb-log-analyzer
    
  • Start Container

    docker run -it --rm dmdhrumilmistry/elb-log-analyzer "elb_log_analyzer -h"
    

Metadata

Release files for elb-log-analyzer 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elb-log-analyzer 0.5.0
File Size Uploaded Provenance
elb_log_analyzer-0.5.0.tar.gz 10.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for elb-log-analyzer 0.5.0
File Interpreter ABI Platform
elb_log_analyzer-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / elb_log_analyzer-0.5.0.tar.gz

Download URL elb_log_analyzer-0.5.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bc9c4254cffa7e4fb483b63fd483061798eae5385d2b676d8a5e00e90ae80a60
BLAKE2b-256 checksum
How to use checksums
8c4d1fa3057770bf064f2d5739ee7f8f1347cec0bfbc1474281ff67c3e6163ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.2 Darwin/22.3.0

Release files / elb_log_analyzer-0.5.0-py3-none-any.whl

Download URL elb_log_analyzer-0.5.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4937fd69c491db217361ee68db20799c3c7981b3f19db683c0270bb5d973c188
BLAKE2b-256 checksum
How to use checksums
17486abb533c560f24490d7679792f1b9766588eb68fc41efe3de4e409c2524a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.2 Darwin/22.3.0

Security for elb-log-analyzer 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page