Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code that downloads all of the log files ending in `.log` in an S3 bucket and counts the total number of HTTP errors in

Write code that downloads all of the log files ending in `.log` in an S3 bucket and counts the total number of HTTP errors in those logs.

Log lines are in the format `{"path": "/", status: 200}` or `{"path": "/", status: 404}`, for example. (This is JSON, and you can process it as such if you choose.)

Use the bucket `class6-logs`, the access key ID "AKIASUMBPHIPY6DLZ4C5", and the secret access key "JQdQIbxsRcipnoKFnsfse44SMRGouzz4tbAzTYbe".

Use the code below to get started:

Code-

import boto3

client = boto3.client(

's3',

aws_access_key_id="AKIASUMBPHIPY6DLZ4C5",

aws_secret_access_key="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",

)

resp = client.list_objects(Bucket='class6-logs')

client.download_file('class6-logs', resp['Contents'][0]

['Key'], 'downloaded_file')

# for object in resp['Contents']:

# print(object['Key'])

# print(resp['Contents'][0]['Key'])

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

To achieve this you can iterate through each log file in the S3 bucket download them locally read ea... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Operating System questions

Question

Define deferred revenue. Why is it a liability?

Answered: 1 week ago

Question

Explain the difference between design and operational decisions.

Answered: 1 week ago