This topic describes how to configure Tracing Analysis in the API Gateway console to upload logs to the Alibaba Cloud Tracing Analysis platform. Tracing Analysis provides tools such as call trace restoration, request volume statistics, topology maps, and application dependency analysis to help improve development and diagnostic efficiency. This feature is available only for dedicated instances.
Prerequisites
A dedicated instance of API Gateway is used.
Grant permissions to Tracing Analysis
Log on to the Tracing Analysis console.
On the Overview page, click Authorize Now to grant Tracing Analysis permission to read and write your Simple Log Service data.
On the Cloud Resource Access Authorization page, select the required permissions and click Confirm Authorization Policy.
After authorization, go to the Overview page from the navigation pane on the left. In the Access Process section, click View Access Point Information. On the Access Point Information page, turn on Show Token and select Jaeger as the Client-side Collection Tool. You can then find and save the endpoint address in the Report Data over HTTP section.
Configure trace analysis in API Gateway
Log on to the API Gateway console.
In the navigation pane on the left, choose API Management > API Groups. In the API Groups list, click an API group to open the Group Details page. On the Group Details page, configure the following parameters.
Trace Field Position: Specify the location of the trace field. Valid values are Header and Query.
Tracing Field Name: Specify the name of the traced field.
The traced field is generated by a client. API Gateway passes the traced field to the backend service and records the traced field in the CustomTraceId field. API Gateway uses the value of the traced field as a trace ID to report logs to Tracing Analysis. The value of the traced field must be in the standard TraceId format, which is a 16-bit or 32-bit hexadecimal number.
If the client does not generate the traced field or the field value is not in a valid format, API Gateway generates a random trace ID to report logs to Tracing Analysis.
Pass through or generate EagleEye-related headers (Eagleeye-Rpcid, Eagleeye-Traceid, Eagleeye-Sampled): If you select this option, API Gateway passes the EagleEye-related headers from the client to the backend service. If the client does not send these headers, API Gateway generates and passes them to the backend service. (This feature is available for Serverless and dedicated instances).
Pass through or generate B3-related headers (X-B3-traceid, X-B3-Parentspanid, X-B3-Spanid, X-B3-Sampled): If you select this option, API Gateway passes the B3-related headers from the client to the backend service. If the client does not send these headers, API Gateway generates and passes them to the backend service. (This feature is available for Serverless and dedicated instances).
Upload Trace Logs to Alibaba Cloud Tracing Analysis (For dedicated instances only):
App Name: Specify the name of the application for which you want to configure tracing analysis.
Endpoint: Enter the endpoint address from Step 4 in Grant permissions to Tracing Analysis. If your services are in the same region, use an internal network endpoint for better performance.
Log Sampling Strategy: Select an option based on your requirements. Valid values: Upload all, Percentage upload, and Fixed number of uploads per second.
After you configure Tracing Analysis in the API Gateway console, you can view request traces in the Tracing Analysis console. For more information about how to use Tracing Analysis, see View API call details.