Skip to content

Millions of logfiles in my bucket

0

I have had this bucket for a couple of years now, storing downloadable content for my online-shop.

now recently i noticed, there's an incredible amount of small logfiles in my bucket, right next to my folders. they're sometimes just a couple of seconds apart. i've never seen them, and i don't really know where they come from (i assume they're from AWS and i activated it by accident?) i tried deleting them manually, but you can only select 300 at a time, and after i did that 20 times and only progressed a couple of days, i stopped. also, it's NOT POSSIBLE to click the column headers to change the sorting.

does anyone know how i can safely delete them (i don't need them), and prevent new ones from being created (at least here?)

Enter image description here

asked 2 years ago296 views

2 Answers
2

Hello.

Try setting up S3 lifecycle rules.
If you look at the log file in the image, the file name prefixes all start with "log_", so I think it will disappear if you set "log_" as the prefix when setting the S3 life cycle rule.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html#how-to-set-lifecycle-configuration

If versioning is not set in S3, it will be deleted after 1 day by setting the following rule.
a

a

By the way, please note that there is a lag in the timing of deletion, so it will not be deleted immediately.
https://repost.aws/knowledge-center/s3-lifecycle-rule-delay

S3 lifecycle runs only once per day. Additionally, Amazon S3 rounds the transition or expiration date of an object to midnight UTC the next day. For example, you create an object on 1/1/2020 10:30 UTC with a lifecycle rule to transition the object after 3 days. For this object, the transition date is 1/5/2020 00:00 UTC. Before you check whether a lifecycle rule is satisfied, be sure to verify that enough time elapsed.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

1

It sounds like you've accidentally enabled server access logging for your S3 bucket, which has resulted in the accumulation of numerous small log files over time. These logs can indeed pile up quickly, especially for frequently accessed buckets. Here's how you can address this issue:

  1. Delete existing log files: Instead of manually deleting files through the console, which is impractical for millions of objects, you can use Amazon S3 Lifecycle configuration. This allows you to automatically delete objects after a specified time period. You can set up a lifecycle rule to delete all objects with a specific prefix (e.g., "logs/") after a certain number of days.

  2. Prevent new log files from being created: To stop generating new log files, you need to disable server access logging for your bucket. You can do this through the S3 console or using AWS CLI/SDK.

  3. Optimize storage and reduce costs: For the existing logs, if you need to retain them for compliance or auditing purposes, consider using a compaction strategy. This involves combining many small log files into fewer, larger objects. This can help reduce storage costs and improve query performance if you need to analyze the logs later.

  4. Review your logging needs: Evaluate whether you actually need detailed access logs for your bucket. If you do need logging for security or auditing purposes, consider using AWS CloudTrail instead, which provides a more comprehensive and manageable logging solution for AWS services.

Remember to be cautious when deleting logs, as this action is irreversible. Make sure you don't need the log data before proceeding with deletion.

To implement these changes, you'll need to access your S3 bucket settings through the AWS Management Console or use AWS CLI/SDK commands. If you're not comfortable making these changes yourself, consider seeking assistance from someone with AWS expertise to ensure you don't accidentally affect your bucket's primary content.

Sources
Deleting Amazon S3 log files - Amazon Simple Storage Service
Optimizing storage costs and query performance by compacting small objects | AWS Storage Blog

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.