Skip to content

Instantly share code, notes, and snippets.

@frytg
Last active May 6, 2019 15:01
Show Gist options
  • Save frytg/8fc5d1a2ad0313e0ee13d9cf8a38c6e4 to your computer and use it in GitHub Desktop.
Save frytg/8fc5d1a2ad0313e0ee13d9cf8a38c6e4 to your computer and use it in GitHub Desktop.
Google Cloud

Google Cloud Auth

gcloud auth list
gcloud config set account EMAIL

Google Cloud BigQuery

Load GCS Logs

bq load --source_format=CSV --autodetect --skip_leading_rows=1 --noreplace swr-lab:DATASET.2018_12 gs://LOG_BUCKET/BUCKET_usage_2018_11_*

Google Datastore Index

Deploy a developer index to enable filtering by station and messageTime:

gcloud datastore indexes create PATH_TO_HELPERS_INDEX_YAML --project PROJECT_ID

Then check and confirm to deploy. See result in GCP Console -> Datastore -> Indexes.

Google Cloud Storage

Storage Caching for 24h

gsutil -m setmeta -r -h "Cache-Control:public, max-age=86000" -h "Content-Disposition" gs://BUCKET/SERVICE/img/*

Storage Caching PRIVAT

gsutil -m setmeta -r -h "Cache-Control:privat" -h "Content-Disposition" gs://BUCKET/SERVICE/img/*

Google Docs gsutil setmeta

Storage Sync local folder

gsutil -m rsync local gs://remote

Google Docs gsutil rsync

Storage Public Read

gsutil defacl ch -u AllUsers:R gs://example-bucket

Storage CORS

gsutil cors set LOCAL_CORS_FILE gs://

Storage Logs

  1. Make Logging Bucket gsutil mb -p PROJECT -c regional -l europe-west3 gs://example-logs-bucket
  2. Allow Access gsutil acl ch -g cloud-storage-analytics@google.com:W gs://example-logs-bucket
  3. Make stuff private gsutil defacl set project-private gs://example-logs-bucket
  4. Enable Logging gsutil logging set on -b gs://example-logs-bucket [-o log_object_prefix ] gs://example-bucket
  5. Double check gsutil logging get gs://example-bucket

Storage Analysis

  1. Make BigQuery table
  2. Import "Create from source"
  3. Skip first row
  4. Enter destination
  5. DONE

Google Docs BigQuery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment