Giter VIP home page Giter VIP logo

logs-storage-calculator's Introduction

AWS Logs calculator (WIP)

This little tool helps to estimate the amount of AWS logs your AWS account is generating. Currently it supports:

  • VPC Flow Logs (via CloudWatch Logs or S3)
  • CloudTrail

It tries to guestimate the VPCFL traffic using 2 heuristics:

  1. Calculate it from CloudWatch Logs (using the new CWL Insights query lang) - OR-
  2. Estimate it from (zipped) S3 daily sample (using an 8X COMPRESSION_RATIO constant)

Pre-requisites

Python3

The tool is written in python3 and requires a working python3 environment. To verify:

python3 --version

If your default python installation is python3 then you can replace python3 with just python

AWS Credentials

The tool assumes that a working AWS cli / profile was already set. If in doubt - please consult boto guide : https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html
Your AWS user / role should have some readonly permissions to perfrom a few EC2 describe operations, CloudWatchLogs Insight queries, and to read relevant S3 buckets. This is the list of IAM permissions that is required. It can be added to the relevant user / role as an independant policy.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "storagecalculator",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeVpcs",
                "ec2:DescribeRegions",
                "ec2:DescribeFlowLogs",
                "s3:ListBucket",
                "s3:GetObject",
                "logs:StartQuery",
                "logs:GetQueryResults"
            ],
            "Resource": "*"
        }
    ]
}

Using the tool

the tool assumes the standard AWS (boto) SDK setup. All authentication setup should be done externally using environment variables. If you wish to use the default AWS profile (or your AWS instance's role):

python3 calculator.py

If you wish to use a different profile, use the relevant environment variable as follows:

export AWS_PROFILE=<MY PROFILE_NAME> && python3 calculator.py

Similarly, it is possible to set the AWS_ACCESS_KEY_ID (and AWS_SECRET_ACCESS_KEY) variables, but it is left out of this readme.

Results

Pretty self explanatory. The scripts enumerates relevant CWL groups and relevant S3 buckets and estimates the daily/monthy data volume (non compressed).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.