Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling web server access logs for a Google Cloud Storage bucket

I'm using Google Cloud Storage to serve my static website to the public and wondering is there a way to enable Apache/NGINX like access logs for the bucket via the GCP web interface?

like image 678
Justin Avatar asked Jan 27 '17 05:01

Justin


People also ask

What GCP Tool is used to control access to a cloud storage bucket?

In most cases, IAM is the recommended method for controlling access to your resources. IAM controls permissioning throughout Google Cloud and allows you to grant permissions at the bucket and project levels.


1 Answers

GCS does offer access logs, although they arrive as CSV files with a bunch of information and not as Apache logs.

Enabling them is fairly simple. Say you want access logs for bucket "mybucket".

First, create another bucket to hold the access logs. Let's call it "mylogsbucket".

Second, give GCS permission to write logs to that bucket with this gsutil command:

gsutil acl ch -g [email protected]:W gs://mylogsbucket

Third, activate logging:

gsutil logging set on -b gs://mylogsbucket gs://mybucket

Usage logs for mybucket will now show up about once per hour in mylogsbucket, and storage logs recording how much data is being stored will show up once per day.

More documentation on this feature is here: https://cloud.google.com/storage/docs/access-logs

like image 76
Brandon Yarbrough Avatar answered Sep 25 '22 15:09

Brandon Yarbrough