Fastly
Fastly streams log lines in near real time to our HTTPS endpoint. No bucket is involved.
Last checked
Values you receive from us
| Value | Used for |
|---|---|
<ENDPOINT_URL> |
HTTPS logging endpoint |
<BEARER_TOKEN> |
Authorization header value |
Send us your service ID
Before Fastly sends logs to an HTTPS endpoint, it verifies that the endpoint accepts logs from your service: it requests /.well-known/fastly/logging/challenge on the endpoint host and expects the SHA-256 hash of your service ID there. Send us the service ID of each Fastly service you want to include, so we can publish its hash before you create the endpoint. You find it in the Fastly control panel next to the service name.
Create the HTTPS logging endpoint
- Open the service, select Edit configuration and clone the active version.
- Go to Logging, find HTTPS and select Create endpoint.
- Configure the endpoint with the values below, paste the log format template and create the endpoint.
- Activate the new version with Activate on Production.
| Setting | Value |
|---|---|
| Name | EINBLIQ.IO |
| Log format | The template below |
| URL | <ENDPOINT_URL> |
| Content type | application/json |
| Custom header name | Authorization |
| Custom header value | Bearer <BEARER_TOKEN> |
| Method | POST |
| JSON log entry format | Newline delimited |
Leave placement, batching limits and compression at their defaults unless we agree otherwise.
Log format template
{
"timestamp_utc": "%{strftime(\{"%Y-%m-%dT%H:%M:%S%z"\}, time.start)}V",
"client_ip": "%{req.http.Fastly-Client-IP}V",
"host": "%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V",
"cmcd_request": "%{json.escape(req.http.CMCD-Request)}V",
"cmcd_object": "%{json.escape(req.http.CMCD-Object)}V",
"cmcd_status": "%{json.escape(req.http.CMCD-Status)}V",
"cmcd_session": "%{json.escape(req.http.CMCD-Session)}V",
"request_query_parameter": "%{json.escape(req.url.qs)}V",
"url": "%{json.escape(req.url)}V",
"request_referer": "%{json.escape(req.http.referer)}V",
"request_user_agent": "%{json.escape(req.http.User-Agent)}V",
"fastly_server": "%{json.escape(server.identity)}V",
"fastly_is_edge": %{if(fastly.ff.visits_this_service == 0, "true", "false")}V
}The template logs CMCD from both the query string and the four CMCD headers, so header-based players such as Apple AVPlayer are covered without further changes.
Keep CMCD out of the cache key
Fastly’s default cache key is the full URL including the query string, so a CMCD parameter creates a separate cache entry for almost every request. Remove the parameter from the cache key in vcl_recv, after copying it for the log:
sub vcl_recv {
# Keep the CMCD value for logging before removing it from the URL.
set req.http.X-CMCD = subfield(req.url.qs, "CMCD", "&");
set req.url = querystring.filter(req.url, "CMCD");
}Check the delivery
Fastly sends log lines within seconds once the version is active. Tell us when it is live; we confirm that log lines arrive and contain CMCD for your players.