Scenarios
By default, the AI gateway provides you with real-time log service and simple search capability for the gateway, free to use.
By default, logs are primarily categorized into user access logs and gateway error logs. You can view the AI Gateway's access logs to understand request-related information for data analysis, audit, and business troubleshooting. You may also check the AI Gateway's error logs to locate issues.
Access logs (accessLog) record information related to users' requests and can be used for data analysis, audit, and business troubleshooting.
Error logs (errorLog) are error logs of the gateway, which are used for gateway troubleshooting.
This document describes the usage instructions for the AI Gateway default log feature.
Prerequisite
AI gateway instances have been created. For detailed operations, see Create AI Gateway. Viewing Default Logs
2. On the instance list page, click the "ID" of the gateway instance to be configured to go to its basic information page.
3. Click Data Observation > Default Logs in the left sidebar.
4. Set the logs you want to view. Related log content is displayed on the page. You can query related logs by keywords. For example, enter "info" to query related logs. Note that log search is case-sensitive.
Edit Default Log Rule
On the Default Log page, click Edit Logging Rule in the upper right corner to modify the default log rules. You can choose to continue to use the default rules or customize log rules based on your business requirements.
Note:
After the default log rules are modified, the log rules of logs shipped to Cloud Log Service (CLS) are also modified. Proceed with caution.
Log Fields
The following table lists the access log fields supported by the AI gateway. You can configure them as needed:
HTTP/HTTPS Log Fields
|
$remote_addr | Client address. |
$status | HTTP status code. |
$remote_user | Username provided in basic authentication. |
$time_local | Request time. |
$request | Complete request line. |
$body_bytes_sent | Body size of the file sent to the client. |
$request_method | Request method. |
$host | Value of the Host field when a request carries the Host request header or the virtual domain name of the host when the request does not carry the Host request header. |
$upstream_addr | IP address of the backend service. |
$upstream_status | HTTP response code in the response returned by the upstream service. |
$upstream_response_time | Upstream service response duration (in milliseconds), from when the gateway establishes a connection to the backend service and receives data to when it disconnects the connection. |
$scheme | HTTP or HTTPS protocol. |
$url | Request URL. |
$request_length | Request data size, in bytes, including the request line, request header, and request body. |
$bytes_sent | Number of bytes of the response. |
$http_referer | Page source, that is, the URL of the page referenced by the header Referer. |
$http_user_agent | Client agent information. |
$request_time | Request duration, from when a request is received to when response data is sent, including receiving request data, processing the request, and returning response data. |
Nginx Variables
Unsupported Nginx variables:
1. The following variables:
$connection_time
$http3
$jwt_claim_
$jwt_header_
$jwt_payload
$memcached_key
$mqtt_preread_clientid
$mqtt_preread_username
$otel_parent_id
$otel_parent_sampled
$otel_span_id
$otel_trace_id
$proxy_protocol_tlv_
$proxy_protocol_tlv_aws_vpce_id
$proxy_protocol_tlv_azure_pel_id
$proxy_protocol_tlv_gcp_conn_id
$secure_link
$secure_link_expires
$session_log_binary_id
$session_log_id
$slice_range
$ssl_alpn_protocol
$ssl_curve
$upstream_queue_time
2. Variables starting with geo