Skip to main content
Google Cloud CDN

Stream logs from Google Cloud CDN via Pub/Sub

This integration ingests Google Cloud CDN (HTTP Load Balancer) request logs into Promptwatch using a Pub/Sub topic, push subscription, and a Log Router sink. Make sure to only route logs from your project’s website.

Prerequisites

  • You are using Google Cloud CDN / HTTP(S) Load Balancer
  • You have access to the GCP project and permissions to create Pub/Sub resources and Log Router sinks

Step 1: Service Account (Verification)

If you already know the service account email you’ll use to authorize this setup, note it down. You’ll need it when creating the push subscription in Step 3. In Promptwatch, navigate to Crawler Logs → Settings, click the Google Cloud button, and enter the service account email you select when creating the push subscription. This lets Promptwatch validate incoming requests.
The service account email is used for verification. During the creation of the Pub/Sub push subscription, you’ll select a service account for authentication.

Step 2: Create Pub/Sub Topic

In Google Cloud Console, create a Pub/Sub topic for your Cloud CDN logs. Create Pub/Sub topic
  • Navigate to Pub/SubTopics
  • Click Create topic, name it, and create it

Step 3: Create Push Subscription

Create a push subscription for the topic you created. Create Pub/Sub push subscription
  • Navigate to Pub/SubSubscriptions
  • Click Create subscription
  • Give your subscription an ID
  • Select the topic you created in Step 2
  • Set Delivery type to Push
  • Set the endpoint URL to:
  • Click Enable authentication and select a service account
  • Enable payload unwrapping
Use the same service account email here as the one you’ll save in Promptwatch (Step 1).
You can also adjust retention, retry policy, and throughput settings in this setup.

Step 4: Add Message Transform

Add a Pub/Sub message transform to reduce the payload before sending to Promptwatch. Add a subscription transform
  • In your subscription, click Add a transform
  • Set the function name to log_reduce
  • Paste this function and click Validate:
This transform drops unneeded fields before sending to Promptwatch. It reduces export volume, improves performance, and enhances data security.

Optional: Filter on known AI Crawler user agents

Promptwatch identifies AI crawlers automatically and only stores AI crawler visits, all other traffic is discarded. You can safely send all your server logs without worrying about non-crawler data being retained. If you prefer to only forward AI crawler traffic, you can use the user agents listed below to pre-filter on your side. Keep in mind that you’ll need to maintain this list yourself as new crawlers emerge.

Step 5: Create Log Router Sink

Create a Log Router sink to export the HTTP Load Balancer logs into your Pub/Sub topic. Create a Log Router sink
  • Search for Log Router (or go to Logging → Log Router)
  • Click Create sink
  • Give your sink a name
  • For destination, choose Cloud Pub/Sub topic and select the topic from Step 2
  • Add a filter similar to the following:
Replace MY-FORWARDING-RULE-NAME and MY-URL-MAP-NAME with your real values. Use “Preview logs” in Log Router to confirm what will and won’t be exported.
If you have multiple load balancers / URL maps, expand the filter like this:
If you are registering multiple domains, create a separate service account per domain and save the correct service account email in Step 1 for each project.

Step 6: Save Service Account in Promptwatch

In Promptwatch, navigate to Crawler Logs → Settings, click the Google Cloud button, and enter the service account email you selected when creating the push subscription in Step 3. Google Cloud CDN settings Once your first crawler traffic hits your site, logs should begin appearing in Promptwatch.
For a full list of API response codes, see API Response Codes.