Skip to content

Vercel log drain endpoint to ingest logs into Google Cloud Logging

License

Notifications You must be signed in to change notification settings

kym6464/vercel-google-cloud-logging

Repository files navigation

vercel-google-cloud-logging

A publicly accessible HTTP endpoint, deployed to Google Cloud Functions, to serve as a Vercel log drain to ingest logs into Google Cloud Logging. This only converts some fields from the Vercel log to their Cloud Logging counterparts.

Setup

(1) Generate a secret key of length 32 (minimum length allowed by Vercel):

python -c 'import secrets; print(secrets.token_hex(16))'

(2) Create file env-vars.yaml based on env-vars.yaml.example and set all variables except VERCEL_VERIFICATION_KEY.

(3) Deploy to google cloud so that you can obtain the public URL:

gcloud functions deploy vercel-log-drain \
  --gen2 \
  --runtime=python312 \
  --region=us-east4 \
  --trigger-http \
  --max-instances 10 \
  --concurrency=10 \
  --cpu=1 \
  --memory="256MB" \
  --allow-unauthenticated \
  --env-vars-file=env-vars.yaml \
  --source=. \
  --entry-point=on_log

... wait for command to complete and copy the Cloud Function URL.

(4) Create a log drain in Vercel with the following options:

  • Delivery Format: JSON
  • Custom Secret: secret generated in step 1
  • Endpoint: The URL of the Cloud Function deployed in step 3

When you enter the Endpoint URL, Vercel will ask you to verify that you own the URL. Set VERCEL_VERIFICATION_KEY in env-vars.yaml and redeploy (step 3). Wait for the deployment to finish then click Verify in Vercel.

(5) Redeploy (step 3)

Development

Local testing:

  1. Start the server GCP_PROJECT="TODO" SECRET_KEY="TODO" functions-framework-python --target=on_log
  2. Make a request curl localhost:8080

Run tests:

python -m tests.test_transform

Useful documentation:

About

Vercel log drain endpoint to ingest logs into Google Cloud Logging

Topics

Resources

License

Stars

Watchers

Forks

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy