Skip to main content

Push logs to S3

Project description

https://img.shields.io/pypi/v/s3logs.svg?style=flat-square https://img.shields.io/pypi/dm/s3logs.svg?style=flat-square

Get files from directory by mask and push them to S3

Install

pip install s3logs

Usage

s3logs config.conf

Where config.conf can use that structure:

[S3]
access_key = <S3_KEY>
secret_key = <S3_SECRET_KEY>
host = <s3.example.com>
bucket = <bucket_name>
chunk_size = <bytes, default=52428800>

[logs]

suffix = .gz
key_suffix = .gz
directory = /var/log/nginx/
depth = 30

[map]

example.com-access.log = example/access
example.com-error.log = example/error
mysite.me.access.log = mysite/access

When it used with that config, script takes all files in directory /var/log/nginx/, filter only those, which ends with .gz and send it to S3, according to map.

For example, /var/log/nginx now consists of:

example.com-access.log
example.com-access.log.0.gz
example.com-access.log.1.gz
example.com-error.log
example.com-error.log.0.gz
example.com-error.log.1.gz
mysite.me.access.log
mysite.me.access.log.0.gz
mysite.me.error.log
mysite.me.error.log.0.gz

So, if today is 9 December 2015, and your hostname is node1, on your S3 <bucket_name> would be those keys:

node1/example/access/2015-12-09.gz
node1/example/access/2015-12-08.gz
node1/example/error/2015-12-09.gz
node1/example/error/2015-12-08.gz
node1/mysite/access/2015-12-09.gz

Because we have not explain how maps mysite.me.error.log.0.gz - it would be skipped.

Script also checks whether file exists in S3 and push only those, which are not.

Parameter depth stops pushing, if filename is older, than .<depth>.gz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3logs-1.8.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file s3logs-1.8.tar.gz.

File metadata

  • Download URL: s3logs-1.8.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.15

File hashes

Hashes for s3logs-1.8.tar.gz
Algorithm Hash digest
SHA256 88b7ed2e501465e4a770d44f80087b071f8ac0d376161dbfdb8449fa44c6612a
MD5 41602c3742357e19abb41505ef62389d
BLAKE2b-256 1ec41fc905d2dd3c56912ce3ce7d2b71fe61a5aa2f574c05e6a48c860ce3d8be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page