Skip to main content

Automated serverless logging to S3 via SQS.

Project description

sqs-s3-logger

A library to persist messages on S3 using serverless architecture. It is mainly targeted at cheaply archiving low-volume, sporadic events from applications without a need to spin additional infrastructure.

Overall idea

What it’s not

Not a replacement for general logging systems or libraries. Provides no filtering or aggregation.

AWS Alternatives

Usage

Configure boto3’s credentials as per: http://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration

Make sure you setup:

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY

  • AWS_DEFAULT_REGION (optionally)

Take a look at main.py.

For help: python3 main.py -h

For example (backup at midnight each Saturday from app-logs queue to app-logs-archive bucket):

sqs-s3-logger create -b app-logs-archive -q app-logs -f app-logs-backup -s 'cron(0 0 ? * SAT *)'

Sending messages to a queue

Ideally you should use another AWS IAM user with permissions restricted to getting SQS queues and writing messages.

import boto3
sqs = boto3.resource('sqs')
queue = sqs.get_queue_by_name(QueueName='<QUEUE_NAME>')
queue.send_message(MessageBody='<MSG_BODY_NOT_EXCEEDING_256KB>')

Limitations

  • Maximum SQS message size is limited to 256 KB

  • There could be no more than 120,000 messages in a queue at a time.

  • SQS messages cannot persist for longer than 14 days.

  • Lambda environment has up to 512MB of ephemeral disk capacity.

  • By default it does not guarantee correct time-based ordering

You may need to adjust your CRON settings depending on your volume.

Testing

python3 setup.py test

These will use your AWS account to instantiate a temporary integration environment.

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

sqs-s3-logger-1.0.7.tar.gz (11.6 kB view details)

Uploaded Source

File details

Details for the file sqs-s3-logger-1.0.7.tar.gz.

File metadata

  • Download URL: sqs-s3-logger-1.0.7.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqs-s3-logger-1.0.7.tar.gz
Algorithm Hash digest
SHA256 2023729a28a554c1820bd0484f44b86754a3566dfb5753bb8571598e28e81b33
MD5 984408ae0bb5ba523d3d8145e44e53ae
BLAKE2b-256 c0090bc569ee0378b834a7d2a264a43762927d9b0e6918260a872cf183c919b0

See more details on using hashes here.

Supported by

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