- English
- 日本語
Useful variables to log
Last updated 2023-10-12
In addition to the standard logging directives, the following request and response variables can be used for logging when you set up remote log streaming. You can also log any Varnish variable. Consider taking advantage of some of Fastly's extensions to VCL as well.
NOTE
All variables should be prefixed by a percent sign (%
). For more information about string formatting, check out our guide to custom log formats.
IMPORTANT
Be sure to take into account security, privacy, and compliance requirements when making configuration and endpoint decisions for the data you intend to include in streamed logs.
Time-related logging variables
These are the time-related variables that can be used for logging.
Variable | Description |
---|---|
%{begin:%Y-%m-%dT%H:%M:%S%z}t | The time of the start of the request in ISO 8601 format. |
%{end:%Y-%m-%dT%H:%M:%S%z}t | The time of the end of the request in ISO 8601 format. |
%{time.elapsed.usec}V | How long the request took in microseconds. |
%{time.start.sec}V | When the request started in Epoch seconds. |
Connection-related logging variables
These are the connection-related variables that can be used for logging.
Variable | Description |
---|---|
%{if(req.is_ipv6, "true", "false")}V | Whether the request was over IPv6 or not. |
%{if(req.is_ssl, "true", "false")}V | Whether the request was over HTTPS or not. |
%{cstr_escape(tls.client.protocol)}V | Which version of TLS was used by the client. |
%{cstr_escape(tls.client.servername)}V | Which SNI server name the client sent. |
%{cstr_escape(tls.client.cipher)}V | Which cipher the TLS request used. |
%{cstr_escape(tls.client.ciphers_sha)}V | Which cipher the TLS request used. |
%{cstr_escape(tls.client.tlsexts_sha)}V | A SHA of the TLS extension identifiers sent from the client as part of the TLS handshake, represented in Base64. |
%{if(fastly_info.is_h2, "true", "false")}V | Whether or not this was an HTTP/2 request. |
%{if(fastly_info.h2.is_push, "true", "false")}V | Whether or not this was an HTTP/2 Push response. |
%{fastly_info.h2.stream_id}V | What the HTTP/2 Stream ID was. |
Request- and response-related logging variables
These are the request- and response-related variables that can be used for logging.
Variable | Description |
---|---|
%{Fastly-Orig-Host}i | The original Host requested if a Host header override is present. |
%{Host}i | The current Host request header (because it could have been modified to send to the origin). |
%{Referer}i | The Referer request header. Specifically, which URL linked to this page. |
%{User-Agent}i | The User-Agent request header. Specifically, which browser requested this page. |
%{Accept}i | The Accept request header. Specifically, the types of content the client can accept. |
%{Accept-Language}i | The Accept-Language request header. Specifically, the human languages the client can respond with. |
%{Accept-Encoding}i | The Accept-Encoding request header. Specifically, the content encoding the client is able to understand. |
%{Accept-Charset}i | The Accept-Charset request header. Specifically, the character set encodings the client accepts. |
%{Connection}i | The Connection request header. Specifically, whether or not the client can do keep-alive connections. |
%{DNT}i | The DNT request header. Specifically, whether or not the client is sending a "Do Not Track" header. |
%{Forwarded}i | The Forwarded request header. Specifically, the originating IP address of a request if this request is proxied. |
%{Via}i | The Via request header. Specifically, the intermediate protocols and recipients between the user agent and the server on proxied requests. |
%{X-Requested-With}i | The X-Requested-With request header. Generally used to identify Ajax requests that will send the value XMLHttpRequest. |
%{X-Requested-For}i | The X-Requested-For request header. Specifically, the originating IP address of a request if this request is proxied. |
%{X-ATT-DeviceId}i | The X-ATT-DeviceId request header. Specifically, the make, mode, or firmware of AT&T devices. |
%{Content-Type}o | The Content-Type response header. Specifically, the MIME type of the content. |
%{TSV}o | The TSV response header. Specifically, the Tracking Status Value suggested for sending in response to a DNT request. |
Cache-related logging variables
These are the cache-related variables that can be used for logging.
Variable | Description |
---|---|
%{If-Modified-Since}i | The If-Modified-Since request header. Specifically, the server will send back the requested resource, with a 200 status, only if it has been last modified after the given date. |
%{If-None-Match}i | The If-None-Match request header. Specifically, the server will send back the requested resource, with a 200 status, only if it doesn't have an ETag matching the given ones. |
%{Cache-Control}o | The Cache-Control response header. Specifically, whether or not all caching mechanisms from server to client may cache this object in seconds. |
%{Age}o | The Age response header. Specifically, the age the object has been in a proxy cache in seconds. |
%{Expires}o | The Expires response header. Specifically, the date and time after which the response is considered stale in "HTTP-date" format as defined by RFC 7231. |
%{Last-Modified}o | The Last-Modified response header. Specifically, the last modified date for the requested object in "HTTP-date" format as defined by RFC 7231. Used in conjunction with the If-Modified-Since request header. |
%{ETag}o | The ETag response header. Specifically, an identifier for a specific version of a resource. Used in conjunction with the If-None-Match Request header. |
%{obj.hits}V | The number of hits this object has (cache specific). |
%{obj.lastuse}V | The last time this object was used (cache specific). |
"cache_status":"%{fastly_info.state}V" | (Fastly-specific) State of the request, with optional suffixes describing special cases. |
Geographic logging variables
These are the geographic variables that can be used for logging.
Variable | Description |
---|---|
%{server.datacenter}V | Which Fastly data center this request hit. |
%{client.geo.city}V | Which city Fastly thinks the request originated from. |
%{client.geo.city.ascii}V | An alias of `client.geo.city`. |
%{client.geo.city.utf8}V | The city or town name associated with the IP address, encoded using the UTF-8 character encoding. |
%{client.geo.country_code}V | Which country Fastly thinks the request originated from. |
%{client.geo.continent_code}V | Which continent Fastly thinks the request originated from. |
%{client.geo.region}V | Which region Fastly thinks the request originated from. |
Size-related logging variables
These are the size-related variables that can be used for logging.
Variable | Description |
---|---|
%{req.header_bytes_read}V | The size of the request headers. |
%{req.body_bytes_read}V | The size of the request body. |
%{resp.header_bytes_written}V | The size of the response headers. |
%{resp.body_bytes_written}V | The size of the response body. |
Socket-related logging variables
These are the socket-related variables that can be used for logging.
Variable | Description |
---|---|
%{client.socket.cwnd}V | The client socket congestion window. |
%{client.socket.nexthop}V | The IP address of the next gateway. |
%{client.socket.tcpi_rcv_mss}V | The client socket max segment size for receiving. |
%{client.socket.tcpi_snd_mss}V | The client socket max segment size for sending. |
%{client.socket.tcpi_rtt}V | The client socket smoothed round-trip time in microseconds. |
%{client.socket.tcpi_rttvar}V | The client socket round-trip time variance in microseconds. |
%{client.socket.tcpi_rcv_rtt}V | The client socket receiver-side estimation of round-trip time in microseconds. |
%{client.socket.tcpi_rcv_space}V | The current buffer space available for receiving data. |
%{client.socket.tcpi_last_data_sent}V | The time since last data sent on client socket in microseconds. |
%{client.socket.tcpi_total_retrans}V | The total number of packet retransmissions on the client socket. |
%{client.socket.tcpi_delta_retrans}V | The change in number of packet retransmissions on the client socket. |
%{client.socket.ploss}V | The client socket packet loss. |
Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.