Send data from Fastly to Axiom
This page explains how to stream Fastly real-time logs to Axiom through the Splunk HEC-compatible API.
Fastly is an edge cloud platform that delivers and caches content for your websites and APIs. Fastly real-time log streaming sends a log line for every request that a Fastly service handles. Stream these logs to Axiom to analyze cache performance, errors, latency, and traffic across Fastly points of presence (POPs).
To send Fastly logs to Axiom, configure a Fastly Splunk logging endpoint that posts to the Axiom Splunk HEC-compatible API. This works for both CDN (VCL) services and Compute services.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to ingest data to the dataset you have created.
- Create a Fastly account with a CDN or Compute service.
Configure the Splunk logging endpoint
In Fastly, create a Splunk logging endpoint for your service. For more information, see the Fastly documentation. Use the following settings:
| Setting | Value |
|---|---|
| Name | A name for the endpoint, for example axiom. For Compute services, use the endpoint name that your code logs to. |
| Placement | Format Version Default |
| Log format | The JSON log format in Recommended log format. CDN services only. |
| URL | https://hec.AXIOM_DOMAIN/services/collector/event |
| Token | The Axiom API token. |
| Use TLS? | Yes. Leave the TLS hostname and certificate fields empty. |
| Maximum logs | 0 (no limit) |
| Maximum bytes | 4194304. This is the maximum request size that Axiom accepts. |
After you create the endpoint, activate the new version of your service. Fastly starts to batch log lines and post them to Axiom. It can take a few minutes after activation before the first events appear in your dataset.
The index field of each log line selects the Axiom dataset. If you leave out index, Axiom sends the events to the dataset that the API token is scoped to, provided that the token grants ingest access to exactly one dataset. For more information, see Choose the target dataset.
Recommended log format
Each log line that Fastly sends must be a Splunk HEC event envelope. Axiom turns the keys of the event object into top-level fields, uses time as the event timestamp, and keeps host, source, sourcetype, and index as fields. For more information, see Event envelope fields.
The following log format for CDN services records the request, the response, the cache state, timing, and the location of the client and the POP. It uses VCL variables and runs in vcl_log, which is the default placement for the current format version. Strings that come from the client pass through json.escape so that each line stays valid JSON.
The format uses the following conventions:
timeis the start of the request in milliseconds since the Unix epoch.- Numeric and Boolean values aren’t quoted, so you can aggregate them in Axiom without converting their type.
cache_statecontains the Fastly cache state, for exampleHIT,MISS, orPASS.fastly_is_edgeistrueon the POP that received the request from the client. If you use shielding, a request can be logged once on the edge POP and once on the shield POP. Filter onfastly_is_edge == trueto count each client request once.
Optional: Remove fields that you don’t need, or add other VCL variables. If client IP addresses are personal data under your privacy policy, remove client_ip or truncate it before it leaves Fastly.
Log from Compute services
Compute services don’t use the Log format setting. Instead, your code writes each log line to the named logging endpoint. Write each line as a JSON object with the same envelope: time, index, and the fields of the request in event. For more information, see the Compute example in the Fastly documentation.
Query Fastly logs
The following query shows the cache hit ratio and the 95th percentile request duration for each POP:
The following query shows the number of server errors over time for each URL:
Add queries like these to a dashboard to monitor your Fastly services. For example, the following dashboard shows traffic, cache performance, latency, and errors across POPs:

Alternative: Generic HTTPS endpoint
Fastly’s HTTPS logging endpoint posts batches of JSON to any HTTPS URL. Before Fastly sends logs to an HTTPS endpoint, it verifies that you control the domain: it requests /.well-known/fastly/logging/challenge on the host in the endpoint URL and expects a list of permitted service IDs in the response. Axiom’s ingest hosts don’t answer this challenge, so you can’t point the HTTPS endpoint directly at the Axiom ingest API. Use the Splunk endpoint instead.
If you already route logs through your own HTTPS gateway that answers the challenge, the gateway can forward the batches to the Axiom ingest API:
- URL:
https://AXIOM_DOMAIN/v1/ingest/DATASET_NAME - Headers:
Authorization: Bearer API_TOKENandContent-Type: application/x-ndjson - Body: newline-delimited JSON. In Fastly, set JSON log entry format to Newline delimited. Leave out the Splunk envelope. Put the fields of the
eventobject at the top level, and renametimeto_timeso that Axiom uses it as the event timestamp.
Send traces from Compute with OpenTelemetry
Optional: To send traces from a JavaScript Compute service, use the @fastly/compute-js-opentelemetry library. Its OTLPTraceExporter sends OTLP/HTTP JSON through a Fastly backend.
-
In your Fastly service, add a backend for the host
AXIOM_DOMAINon port 443 with TLS enabled, and name it, for example,axiom. For more information, see the Fastly documentation. -
Configure the exporter to send traces to the Axiom OTLP endpoint:
javascript
For more information about the Axiom OTLP endpoints, see Send OpenTelemetry data to Axiom.