Skip to main content

AWS CloudFront Setup

The AWS CloudFront integration uses Real-Time Logs with Kinesis Data Streams and Firehose to forward request data to Travatar. This captures every request at the CDN edge - including cached responses.

Prerequisites

  • An AWS account with a CloudFront distribution
  • A Travatar account with an App ID and API Token
  • Access to AWS Console (Kinesis, CloudFront, Lambda)

Architecture

CloudFront (Real-Time Logs)

Kinesis Data Streams

Kinesis Data Firehose

Lambda (transforms records)

POST → Travatar webhook

Setup Steps

1. Get Your Credentials

  1. Log in to app.travatar.ai
  2. Go to Settings → Server Tracking
  3. Copy your App ID and generate an API Token

2. Create Kinesis Data Stream

  1. Go to AWS Console → Kinesis → Data Streams
  2. Click Create data stream
  3. Name: sst-travatar-data-stream
  4. Leave default settings (On-demand capacity mode)
  5. Click Create data stream

3. Create Kinesis Data Firehose

  1. Go to Kinesis → Firehose
  2. Click Create firehose stream
  3. Source: Kinesis Data Streams → select sst-travatar-data-stream
  4. Destination: HTTP endpoint
  5. Name: SST-Travatar-Firehose
  6. HTTP endpoint URL: https://log-tracker.travatar.ai/webhook
  7. Add HTTP headers:
HeaderValue
X-TRAVATAR-SST-TOKENYour API Token from step 1
X-TRAVATAR-SST-SOURCEaws
  1. Create an S3 backup bucket (e.g., sst-travatar-logs) - required for failed deliveries
  2. Click Create Firehose
tip

If creation fails with an IAM role error, try again - AWS sometimes needs a moment to propagate the auto-created role.

4. Configure CloudFront Real-Time Logs

  1. Go to CloudFront → Distributions
  2. From the left sidebar, select Telemetry → Logs
  3. Click Real-time configuration tab → Create new configuration
  4. Name: SST-Travatar-Configuration
  5. Sampling rate: 100%
  6. Fields - select at minimum:
    • timestamp
    • c-ip
    • cs-method
    • cs-uri-stem
    • cs-uri-query
    • sc-status
    • cs-host
    • cs-user-agent
    • cs-referer
    • x-forwarded-for
  7. Endpoint: select sst-travatar-data-stream
  8. IAM role: Create new service role
  9. Distribution: select your distribution, cache behavior: Default (*)
  10. Click Create Configuration

5. Verify

  1. Visit your website
  2. Go to app.travatar.aiAI Traffic
  3. Data should appear within 2-5 minutes (Kinesis adds some buffering delay)

What Data Is Collected

CloudFront Real-Time Logs provide:

FieldDescription
c-ipClient IP address
cs-methodHTTP method (GET, POST, etc.)
cs-uri-stemRequest path (/blog/my-article)
cs-uri-queryQuery string parameters
cs-hostRequested hostname
cs-user-agentBrowser or bot identifier
cs-refererReferring URL
sc-statusHTTP status code
x-forwarded-forOriginal client IP behind proxies

Troubleshooting

No data in dashboard

  1. Check CloudFront Real-Time Log configuration is active
  2. Verify Kinesis Data Stream has incoming records: Kinesis → Data Streams → Monitoring
  3. Check Firehose delivery errors: Firehose → Monitoring → Delivery errors
  4. Verify HTTP headers (X-TRAVATAR-SST-TOKEN, X-TRAVATAR-SST-SOURCE) are correct

Delayed data

Kinesis Firehose buffers records before sending. Default buffer is 60 seconds or 1 MB - whichever comes first. You can lower the buffer interval in Firehose settings (minimum 60 seconds).

Firehose delivery failures

Check the S3 backup bucket for failed records. Common causes:

  • Invalid API token → 401 response
  • Incorrect source header → 400 response