Skip to main content

Upload scrapy logs to S3

Project description

Scrapy S3 Log Storage

Description

A Scrapy extension to upload log files to S3.

If you're already exporting your feeds to S3 this extension uses many of the same settings. After adding this extension to your EXTENSIONS setting, just set the LOG_FILE, S3_LOG_BUCKET and an optional S3_LOG_ACLsettings and you're good to go.

Installation

You can install scrapy-s3logstorage using pip:

    pip install scrapy-s3logstorage

Configuration

This extension still requires that a local log file is written. Once scrapy's engine has stopped, the extension will upload the log file to S3 and optionally delete the local file.

Enable the extension by adding it to your settings.py:

    from environs import Env

    env = Env()  
    env.read_env() 

    EXTENSIONS = {
        'scrapy_s3logstorage.extension.S3LogStorage': 0,
    }

    LOG_FILE = 'scrapy.log' # Must be a local file
    S3_LOG_BUCKET = 'my-bucket' # Bucket name to store logs
    S3_LOG_DELETE_LOCAL = True # Delete local log file after upload, defaults to False

    # If AWS CLI is configured, and you're using the same credentials the following settings are optional
    AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
    AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")
    AWS_SESSION_TOKEN = env("AWS_SESSION_TOKEN") # if required
    AWS_ENDPOINT_URL = None  # or your endpoint URL

    # S3_LOG_ACL takes priority over FEED_STORAGE_S3_ACL.
    # If S3_LOG_ACL is not set, FEED_STORAGE_S3_ACL will be used.
    # Setting one or both of these settings is optional.

    S3_LOG_ACL = ''  # or other S3 ACL
    FEED_STORAGE_S3_ACL = '' # or other S3 ACL

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

scrapy_s3logstorage-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

scrapy_s3logstorage-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file scrapy_s3logstorage-0.1.0.tar.gz.

File metadata

  • Download URL: scrapy_s3logstorage-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-43-generic

File hashes

Hashes for scrapy_s3logstorage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e84294fff20193533e77262f5e87d36dcd0087727fedf2228f021b4a5d9a1d0e
MD5 30b00f87b467286d6e5b97715b2b8558
BLAKE2b-256 dc9aa8466bab43c3242917a05f7f363839a44fb96a93c5c722ace471bd95e261

See more details on using hashes here.

File details

Details for the file scrapy_s3logstorage-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_s3logstorage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e9ce3aac31d145f5f750f625fa062e5a49ff895349c4257bf7f4e4c8ec55713
MD5 4a24a6e4f8e8b26b8f45add720ce0ef5
BLAKE2b-256 ccdcdd351b4d55fd96be8e34029bee5e5a341b25bc0b3cafa6b71274d275c911

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