GithubHelp home page GithubHelp logo

jaimejorge / logspout-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pressly/logspout-s3

0.0 1.0 0.0 958 KB

Logspout Adapter for AWS S3 to send docker logs to S3 - ready for Athena

Makefile 5.84% Shell 3.83% Go 90.33%

logspout-s3's Introduction

Logspout-S3

Logspout-S3 is a container app that listens on the Docker bus and streams application logs to Amazon S3 at some FLUSH_INTERVAL or MAX_SINK_SIZE_MB. It's built as an adapter to github.com/gliderlabs/logspout.

Usage

docker run -d --name=logspout-s3 \
	-e 'BACKLOG=false' \
	-e 'AWS_ACCESS_KEY=YOUR_KEY' \
	-e 'AWS_SECRET_KEY=YOUR_SECRET_KEY' \
	-e 'AWS_REGION=us-east-1' \
	-e 'FLUSH_INTERVAL=120' \
	-e 'MAX_SINK_SIZE_MB=16' \
	--volume=/var/run/docker.sock:/var/run/docker.sock \
	pressly/logspout-s3 \
	s3://pressly-logs-test?path=/logs

See the example/ folder and Makefile to get started. It demonstrates a REST API service with JSON structured logging output, and also the start command for logspout-s3 which will stream those logs.

The s3 url can be just the bucket as in s3://bucketname or you can provide the additional path query param which is the directory to store container logs as in the example usage above.

If you'd like to query the logs, check out https://aws.amazon.com/athena/ which uses S3 as a backend for any kind of log data to query/visualize.

Image run options

The container app supports a few environment variables as options:

  • AWS_ACCESS_KEY : your AWS access key
  • AWS_SECRET_KEY : your AWS secret key
  • AWS_REGION : the AWS region where your S3 bucket resides
  • FLUSH_INTERVAL : interval that collected logs are then uploaded to S3, as seconds (default: 120)
  • MAX_SINK_SIZE_MB : max buffer size for log collection before sending to S3, as MB (default: 16)

as well, the container command where in above example its s3://pressly-logs-test can also accept additional paths as the folder prefix, ie. s3://pressly-logs-test/logs

Tips

Setup an IAM user with the S3 policy to only write access to your logging buckets, like:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:PutObject"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::pressly-logs-test",
                "arn:aws:s3:::pressly-logs-test/*"
            ]
        }
    ]
}

LICENSE

MIT

logspout-s3's People

Contributors

vojtechvitek avatar

Watchers

James Cloos avatar

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.