Skip to content
Fastly Integration

Fastly Integration

Stream Fastly access logs to Airefs with an HTTPS log streaming endpoint. Works on all Fastly plans, no code changes to your service logic.

Updated
Ask AI
View as Markdown

Fastly’s real-time log streaming sends every request to Airefs, where bot traffic is classified and assets and error responses are dropped server-side. This powers AI Impressions; to also track Clicks, add the client-side tracking script from Site Settings → Tracking Script.

Your access token is in your Airefs account under Site Settings → Access Token.

Setup

  1. In the Fastly control panel, open your service, click Edit configuration, and go to Logging.
  2. Create a new HTTPS endpoint with these settings:
SettingValue
URLhttps://api.getairefs.com/v1/logs/fastly
MethodPOST
Content typeapplication/json
Custom header nameX-API-Key
Custom header valueyour Airefs access token
JSON log entry formatArray of JSON
Log line formatBlank
Format version2
Maximum bytes per request5000000 (5 MB)
  1. Set the log format to exactly this template:
{"event_id":"%{req.xid}V","timestamp":"%{begin:%Y-%m-%dT%H:%M:%S%z}t","client_ip":"%{req.http.Fastly-Client-IP}V","hostname":"%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V","request_path":"%{json.escape(req.url.path)}V","query_string":"%{json.escape(req.url.qs)}V","request_method":"%{json.escape(req.method)}V","status_code":%{resp.status}V,"content_type":"%{json.escape(resp.http.Content-Type)}V","user_agent":"%{json.escape(req.http.User-Agent)}V","referrer":"%{json.escape(req.http.Referer)}V","country_code":"%{client.geo.country_code}V"}
  1. Attach this response condition so shielded requests are logged only at the edge POP:
fastly.ff.visits_this_service == 0

If the service fronts multiple domains, combine the shielding guard with your tracked hostname:

fastly.ff.visits_this_service == 0 && req.http.host == "yourdomain.com"
  1. Activate the new service version.

Fastly validates log destination domains automatically against Airefs’s /.well-known/fastly/logging/challenge endpoint — there is nothing to configure for it.

Verification

Visit a few pages served by Fastly. Events appear in your Airefs dashboard within a few minutes.

Outside dry-run mode, a successful response means Airefs stored every accepted record and reports why the rest were dropped. For a one-off test before going live, POST a sample record with ?dry_run=1 appended to the endpoint URL: Airefs returns a per-record verdict, including the bot classification it detected, without storing anything.

No events? Confirm the X-API-Key header value is your exact access token (a wrong token returns 401, which Fastly does not surface prominently) and the log format matches the template exactly. Need help? Email support@getairefs.com.