Skip to main content

Connecting your website to Agent Traffic using Fastly HTTPS Log Streaming

Setting up Agent Traffic for Fastly

Updated over 2 weeks ago

Overview

Agent Traffic is Scrunch’s bot analytics tool that monitors access from AI bots like ChatGPT, Perplexity, Gemini, and Grok. This guide shows you how to stream traffic logs from Fastly to Scrunch using HTTPS log streaming.

Fastly HTTPS log streaming sends real-time access logs to Scrunch’s webhook endpoint, allowing near-instant visibility into bot traffic on your site.

Note: This is a pilot feature and you need to ask Scrunch customer service to enable and onboard you.

What You’ll See

Once integrated, the Agent Traffic dashboard will show:

  1. Total bot traffic metrics - Overall volume and trends

  2. Traffic distribution by bot type - Breakdown between Retrieval bots (ChatGPT), Indexer bots (Google), and Training bots (GPTBot)

  3. Top bot agents - Which specific bots are accessing your site most frequently

  4. Top content pages accessed - Which pages bots are visiting

  5. Traffic timeline - Historical view of bot activity

  6. Status code distribution - Success rates (200s) vs errors (404s, etc.)

  7. Method breakdown - GET, POST, and other HTTP methods used by bots

  8. Date filtering options - View data for the last 24 hours, 7 days, or 30 days

Adding Your Website

Before configuring Fastly, add your domain in Scrunch to get credentials:

  1. Log into your Scrunch account at app.scrunchai.com

  2. Click Agent Traffic in the main menu

  3. Click Connect Site or Add Domain

  4. Enter your domain name (e.g., example.com)

  5. Select Fastly as the platform

  6. Click Create

After creating the site, you’ll see two credentials on the site detail page:

  • Webhook URL - Format: https://webhooks.scrunchai.com/v1/sites/[SITE_ID]/platforms/fastly/web-traffic

  • Authentication Token - A long string starting with eyJ...

Keep these credentials handy for the next section.

Integrating Fastly HTTPS Log Streaming

Step 1: Open Fastly Control Panel

  1. Navigate to Services and select your CDN which contains the domain you added above to ScrunchAI

  2. Click Service configurationClone to edit to create a draft (new version, inactive)

Step 2: Create HTTPS Logging Endpoint

  1. In the left sidebar, click Logging

  2. Scroll to the HTTPS section and click Create endpoint

Step 3: Configure Basic Settings

Enter the following in the endpoint form:

  • Name: Scrunch Agent Traffic

  • Placement: Format Version Default

  • Log Format: Check below for the content to paste there

  • URL: Paste your Webhook URL from Scrunch

  • Maximum logs: 10000

  • Maximum bytes: 10485760

  • Processing region: US

  • Content type: application/json

  • Custom header name: X-Api-Key

  • Custom header value:[YOUR_TOKEN] (replace [YOUR_TOKEN] with your authentication token from Scrunch)

    • Important: Do NOT include Bearer before the Token.

  • Method: POST

  • JSON log entry format: Array of Json

  • Select a log line format: Blank

  • Compression: None ← Make sure to select this, the default value will not work unless it’s explicitly None (Pure JSON)

  • Using your own certificate authority (CA): Leave all fields under this empty

  • Press Save after all of the above is entered. You will go back to the Version page.

  • Click on “Activate” so it starts applying

    • You are activating a new Version of Configuration which now includes this new Logging Endpoint

Log format:

{   "timestamp": "%{begin:%Y-%m-%dT%H:%M:%SZ}t",   "host": "%{req.http.Host}V",   "method": "%m",   "path": "%{json.escape(req.url.path)}V",   "status": %{resp.status}V,   "user_agent": "%{json.escape(req.http.User-Agent)}V",   "client_ip": "%h",   "pop": "%{server.datacenter}V",   "service_id": "%{req.service_id}V" }

Step 4: Verify Traffic

After activation, generate some test traffic:

  1. Visit your website: https://yourdomain.com

    1. Make sure you are reaching your website via the domain you configured in Fastly!

  2. Navigate to a few different pages

  3. Wait 30-60 seconds for logs to appear

  4. Check your Scrunch Agent Traffic dashboard , you should see the traffic within 1-2 minutes.

  5. Your website should be active and you should be seeing the bot traffic for that domain now!

Troubleshooting and Tips

No traffic appearing after 5 minutes?

  1. Test the endpoint: In Fastly Control Panel → Logging → Find your Scrunch endpoint → Click Test. Fastly will send a test request.

  2. Check for errors: Look for 401, 403, or 404 errors in the test result

  3. Verify Authorization header: Make sure you included Bearer before the token

  4. Check service activation: Ensure you clicked “Activate” (not just “Save”)

  5. Verify domain: If using domain filtering, make sure the filter condition is correct

Common issues:

  • 401 Unauthorized: Authorization header is missing Bearer prefix or token is incorrect

  • 404 Not Found: Webhook URL is incorrect (check the site ID in the URL)

  • No test traffic showing: Make sure you’re visiting the correct domain that matches your filter condition

Tips for multiple domains:

If you have multiple domains on one Fastly service, create a separate site in Scrunch for each domain, then:

  1. Create separate HTTPS logging endpoints for each domain

  2. Name them distinctly: Scrunch - example.com, Scrunch - shop.example.com

  3. Use domain filtering to ensure each endpoint only sends logs for its specific domain

Data appears delayed:

Fastly batches logs every 10 seconds or when reaching 10,000 entries / 10 MB. During low traffic periods, logs may take up to 10 seconds to appear. This is normal.

Optimizing data quality:

  • Fastly HTTPS logging is free but counts toward bandwidth usage (logs are gzipped, so impact is minimal)

  • If you see excessive unmatched domains in Scrunch, add domain filtering to reduce noise

  • Consider filtering out static assets (CSS, JS, images) using response conditions if needed


For additional help, contact [email protected] or use the chat widget in your Scrunch dashboard.

Did this answer your question?