Skip to content

CDNetworks Documentation

Built-in Variables permalink

The table below lists all the built-in variables supported by the CDN Pro servers. You can use them in Edge Logic or Load Balancer Logic. Not all variables are supported in both places. The real-time log supports the same set of variables as the Load Balancer Logic. Most variables here are read-only. The writable ones are indicated by R/W. The variables with numerical values are tagged with #. If you use the CDN Pro portal to edit the property, typing $ at a position where a variable is allowed will list all the supported variables.

Variable NameDescriptionEdge LogicLB Logic
$arg_namequery parameter with the specified nameYesYes
$argsthe full query string from clientYesYes
$body_bytes_sent# body bytes sent to clientNoYes
$bytes_sent# total response bytes to clientNoYes
$cache_misca writable variable to add parameters to the cache keyR/WNo
$client_country_codeclient’s ISO 3166 country codeYesYes
$client_http_versionclient's HTTP version, like "HTTP/1.1"YesYes
$client_ip_version# client's IP version: 4 for IPv4; 6 for IPv6YesYes
$client_ispclient's ISP informationYesYes
$client_province_codeclient's China province codeYesYes
$client_real_ipclient's IP addressYesYes
$connection_requests# current number of requests in the connectionNoYes
$content_codea writable variable to assign a code to content for reporting and billing purposesR/WR/W
$content_length# request's Content-Length headerYesYes
$content_typerequest's Content-Type headerYesYes
$cookie_namecookie with the specified name received from the client. The dot character (.) is allowed in this variable name to support cookie names that contain dots. You may need to use curly braces to separate this variable from a trailing literal dot. For example: $cookie_abc.test or ${cookie_abc.test} both refer to the value of the cookie "abc.test", but ${cookie_abc}.test gives you the value of the cookie "abc" followed by the literal ".test".YesYes
$dollar_signa literal dollar signYesYes
$download_time# the time from when CDN Pro receives the client request until CDN Pro sends the response body to the system buffer, the value should be equal to sum of $request_end_time/$turn_around_time/$transfer_time, in seconds. Another variable download_time_ms shares the same meaning but in milliseconds.NoYes
$error_codeerror about client and originNoYes
$extra_deliver_time_ms# the estimated time in milliseconds needed to flush the TCP send buffer.NoYes
$hosthost header, same as $http_hostYesYes
$hostnameserver's hostnameYesYes
$http_namerequest header with the specified nameYesYes
$http_hostrequest's Host headerYesYes
$ignored_body_in_cache_keyempty string when proxy_request_body_in_cache_key is off, '0' when the request body hash is included in the cache, or '1' otherwiseYesNo
$invalid_refererempty string if the “Referer” request header field value is considered valid; otherwise “1”YesYes
$is_argsempty or "?", when query string existsYesYes
$msec# current Unix time in seconds with milliseconds resolutionYesYes
$sec# current Unix time in integer secondsYesYes
$origin_hostorigin's hostnameYesYes
$origin_iporigin's IPYesYes
$origin_status_codeorigin's status codeYesYes
$pidprocess ID of the serviceYesYes
$pipe"p" if request is pipelined, or "." otherwise.NoYes
$property_ver# the property version numberYesYes
$qtl_cpu_cycle# CPU time in nanoseconds(1e-9s) spent in LB7, and in ES before transferring the response bodyNoYes
$qtl_req_ida unique ID for the requestYesYes
$qtl_upstream_cache_statuscache status: HIT, MISS, BYPASS, EXPIRED, STALE, UPDATING, REVALIDATED.YesYes
$random_N# A random integer uniformly distributed in [0, N-1]. N can be an integer in [2, 1e9].YesYes
$realtime_log_ds_factor# RT log downsample factor. A value N means one log entry for every N requests. Users can set a value to override the default sample rate.NoR/W
$realtime_log_ds_ratio# RT log downsample ratio, the reciprocal of $realtime_log_ds_factor. The value should be a decimal number between 0 and 1.NoYes
$remote_useruser name extracted from the Authorization header if Basic authentication is used.YesYes
$requestfull HTTP request lineYesYes
$request_cpu_time# CPU time, in nanoseconds, spent on processing the request by the ES stage (when used in the Edge Logic), or by the LB stage (when used in the real-time log)YesYes
$request_start_time# the Unix time (in seconds with milliseconds resolution) when the first byte of the request is received from the client.YesYes
$request_end_time# the time in seconds it takes to receive the request header from the client and be ready to process or forward it. Another variable request_end_time_ms shares the same meaning but in milliseconds.NoYes
$request_length# length of request line, header and bodyYesYes
$request_methodHTTP method: GET, POST, etc.YesYes
$request_scheme"http" or "https"YesYes
$request_time# request processing time in seconds with a milliseconds resolution; time elapsed since the first bytes were read from the client. The value is equal to the sum of the values of 3 variables: $request_end_time, $turn_around_time and $transfer_time. When the request and response sizes are small, $request_end_time and $transfer_time may be 0 and $request_time may have the same value as $turn_around_time.YesYes
$request_urirequest URI from the client, beginning with '/' and including the query stringYesYes
$sc_completed# Value is 1 if the last byte was served to the client; 0 otherwise.NoYes
$sc_initial# Value is 1 if the first byte was served to the client; 0 otherwise.NoYes
$sent_http_nameheader with the specified name sent to clientNoYes
$sent_http_content_length# Content-Length to clientNoYes
$served_from_cache# Value is 1 for a HIT on edge; 0 for a MISS.YesYes
$server_addrIP address of the edge serverNoYes
$server_level# Level of the cache server. 1 means edge, and 2 means intermediate.NoYes
$server_nameThe value specified in the property's hostnames that matched the incoming request.YesYes
$server_regionCountry code of the edge server, E.g. CN, USYesYes
$server_protocolHTTP/1.1 or HTTP/2.0NoYes
$service_port# port number that received the requestYesYes
$sorted_querystring_argsvariable providing an ASCII-based sorted list of input query parameters; it can be modified by the "sorted_querystring_filter_parameter" directiveYesYes
$ssl_cipherTLS cipher suite usedNoYes
$request_ssl_handshake_time# CPU time, in nanoseconds, spent on TLS handshakeNoYes
$ssl_protocolreturns protocol name like "TLSv1.1"NoYes
$ssl_server_nameTLS SNI servernameNoYes
$statusHTTP status code to clientYesYes
$tcpinfo_delivery_rate# the rate, in bytes/s, at which the sent data is acknowledged by the client.NoYes
$tcpinfo_min_rtt# minimum RTT, in microseconds, observed by TCP stack for the connectionNoYes
$tcpinfo_rtt# latest RTT, in microseconds, observed by TCP stack for the connectionNoYes
$time_httpcurrent time in RFC 7231 format that can be used for HTTP Date headerYesYes
$transfer_time# the time needed for CDN Pro to send the full requested object ( up to last byte ) to system buffer, in seconds. Another variable transfer_time_ms shares the same meaning but in milliseconds.NoYes
$turn_around_time# the time needed for CDN Pro to receive first byte of response of origin, in seconds. Another variable turn_around_time_ms shares the same meaning but in milliseconds.NoYes
$upstream_bytes_received# number of bytes received from a parent or origin serverYesNo
$upstream_bytes_sent# number of bytes sent to a parent or origin serverYesNo
$upstream_connect_time# time spent in seconds with millisecond resolution establishing a connection with a parent or origin serverYesNo
$upstream_cookie_namecookie with the specified name received from the upstream server in the “Set-Cookie” response header field. May be served from the cache. The dot character (.) is allowed in this variable name to support cookie names that contain dots. You may need to use curly braces to separate this variable from a trailing literal dot. For example: $upstream_cookie_abc.test or ${upstream_cookie_abc.test} both refer to the value of the cookie "abc.test", but ${upstream_cookie_abc}.test gives you the value of the cookie "abc" followed by the literal ".test".YesYes
$upstream_header_time# time spent in seconds with millisecond resolution receiving the response header from a parent or origin serverYesNo
$upstream_http_nameheader with the specified name received from the upstream server. May be served from the cache.YesYes
$upstream_response_statusstatus code from a parent or origin server. Value will be 0 for a cache HIT.YesNo
$upstream_response_time# time spent in seconds with millisecond resolution receiving the complete response from a parent or origin serverYesNo
$upstream_server_type'O' for origin server; 'C' for parent cache server.YesNo
$upstream_trailer_nametrailer with the specified name passed from the Edge Logic with the add_trailer directive.NoYes
$urinormalized request URI beginning with '/' and excluding the query string. The value may be modified by the "rewrite" directive in the Edge Logic.YesYes