> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usequotable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fastly

> Stream Fastly request logs to Agent Analytics through an HTTPS logging endpoint with a ready-made JSON log format.

Fastly's HTTPS logging endpoint streams one JSON line per request from your service to Quotable. Nothing runs in your request path.

## Requirements

* A Fastly service that serves the domain the source is created for.
* Permission to edit the service's logging endpoints and activate a new version.

**What it measures:** every field. Cache status is Fastly's request state (`HIT`, `MISS`, `PASS`…), not an origin cache header. Fastly's timestamp has one-second precision, so the format includes the request start in microseconds to keep two hits on the same path in the same second apart.

## Set up

**1. Create the source in Quotable**

In **Agent Analytics**, select **Connect source**, choose **Fastly** and select **Generate credentials**. Copy the token, the endpoint URL and the **Fastly log format string**.

**2. Add an HTTPS logging endpoint**

In Fastly, open your service, clone the active version, go to **Logging** and create an **HTTPS** endpoint:

| Setting | Value |
| - | - |
| Log format | The format string from the wizard (below) |
| URL | Your endpoint URL |
| Method | `POST` |
| Custom header name | `Authorization` |
| Custom header value | `Bearer aa_live_…` |
| JSON log entry format | Newline delimited (an array also works) |
| Maximum logs | `1000` or fewer |
| Maximum bytes | 5 MB or less |
| Compression | gzip or none |

**3. Activate the version**

Activate the new service version. Before it sends logs, Fastly checks that the endpoint's host accepts logs from your service by requesting `/.well-known/fastly/logging/challenge` on it. Quotable answers that check for every Fastly service, so there is nothing to configure. Logs start flowing on the next requests.

**4. Confirm delivery**

Select **Check now** in Quotable.

## Log format

Paste this exactly. It renders one JSON object per request and deliberately leaves out cookies, authorization headers and the query string (`req.url.path` has no query).

```text theme={"system"}
{"timestamp":"%{begin:%Y-%m-%dT%H:%M:%SZ}t","client_ip":"%h","geo_country":"%{client.geo.country_code}V","host":"%{req.http.host}V","url":"%{req.url.path}V","request_method":"%m","request_referer":"%{req.http.referer}V","request_user_agent":"%{req.http.user-agent}V","response_state":"%{fastly_info.state}V","response_status":%>s,"response_body_size":%B,"time_elapsed":%{time.elapsed.msec}V,"time_start_usec":"%{time.start.usec}V","request_id":"%{req.http.x-request-id}V"}
```

If your service sets an `x-request-id` header, it's used for exact deduplication.

## Rotate the token

1. Rotate the token in Quotable. The old token stops working immediately.
2. Update the custom header value of the endpoint and activate the version.

## Disconnect

Delete the logging endpoint, activate the version, then disconnect the source in Quotable.

## Troubleshooting

| Symptom | Likely cause | Fix |
| - | - | - |
| `401` | Header missing, or token wrong or rotated | Check the custom header is `Authorization: Bearer aa_live_…`. |
| `413` | Batches above 1,000 lines or 5 MB | Lower **Maximum logs** and **Maximum bytes**. |
| `invalid_record` on every line | The log format was changed or truncated | Paste the format string again, unchanged. |
| `host_mismatch` | The service serves other domains | Connect each domain as its own source, or use a separate endpoint per domain. |
| Fastly reports the endpoint failed its ownership check | The URL isn't the endpoint from the wizard, so the host doesn't answer `/.well-known/fastly/logging/challenge` | Copy the endpoint URL again from the wizard, unchanged. If the check still fails, contact support with your source ID. |

## Next steps

> [card] [Read the dashboard](https://docs.usequotable.com/agent-analytics/dashboard.md)
>
> What to look at once data arrives.

> [card] [Troubleshooting](https://docs.usequotable.com/agent-analytics/troubleshooting.md)
>
> Fix deliveries that fail or arrive empty.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.