Updated on 2025-08-28 GMT+08:00

Viewing API Call Logs

APIG provides visualized analysis and statistics of APIs, allowing you to view API calling logs.

Prerequisites

APIs have been called.

Viewing API Call Logs

  1. Go to the APIG console.
  2. Select a gateway at the top of the navigation pane.
  3. In the navigation pane, choose Monitoring & Analysis > Log Analysis.
  4. Enable log analysis.

    1. On the Log Analysis page, click Configure Log Collection.

      If the gateway is in the CN South-Guangzhou region, click Configure Logs and Tracing.

    2. In the displayed dialog box, configure log information and click OK.
    Table 1 Configuring log information

    Parameter

    Description

    Collect Logs

    Indicates whether to enable log collection. By default, it is disabled. You can view API call logs only after the parameter is enabled.

    Log Group

    Select the log group to which the log stream belongs.

    If no log group is available, click View Log Groups to go to the LTS console and create a log group. For details, see Creating a Log Group.

    Log Stream

    Select the log stream for storing the API call logs.

    If no log stream is available, click View Log Streams to go to the LTS console and create a log stream. For details, see Creating a Log Stream.

    APM Applications

    Select one or more APM applications to view the complete tracing and service topology on APM. Currently, this parameter is available only in the CN South-Guangzhou region.

    If no APM application is available, click Create APM Application to create one. For details, see Creating an Application.

  1. After the log analysis function is enabled, view the call logs of all open APIs in real time on the console. For details about the log fields, see Table 2.
  2. To export logs, see Log Transfer.

    Fields in access logs are separated using spaces. The following table describes each log field.

    Table 2 Log field description

    No.

    Field

    Description

    1

    remote_addr

    Client IP address.

    2

    request_id

    Request ID.

    3

    api_id

    API ID.

    4

    user_id

    Project ID provided by a requester for IAM authentication.

    5

    app_id

    Application ID provided by a requester using app authentication.

    6

    time_local

    Request completion time.

    7

    request_time

    Request latency (unit: second).

    8

    request_method

    HTTP request method.

    9

    scheme

    Request protocol.

    10

    host

    Domain name.

    11

    router_uri

    Request URI.

    12

    server_protocol

    Request protocol.

    13

    status

    Response status code.

    14

    bytes_sent

    Response size in bytes, including the status line, header, and body.

    15

    request_length

    Request length in bytes, including the start line, header, and body.

    16

    http_user_agent

    User agent ID.

    17

    http_x_forwarded_for

    X-Forwarded-For header field.

    18

    upstream_addr

    Backend address.

    19

    upstream_uri

    Backend URI.

    20

    upstream_status

    Backend response code.

    21

    upstream_connect_time

    Time taken for establishing a connection with the backend, in seconds.

    22

    upstream_header_time

    Duration from the beginning of the establishment of a connection to receiving the first byte from the backend, in seconds.

    23

    upstream_response_time

    Duration from the start of a connection to the last byte received from the backend, in seconds.

    24

    region_id

    Region ID.

    25

    all_upstream_response_time

    Duration from the start of a connection to the last byte received from the backend, in seconds. When a retry occurs, the value is the total time taken.

    26

    errorType

    API request error type. Options:

    • 0: non-throttling error
    • 1: throttling error

    27

    auth_type

    API authentication mode.

    28

    access_model1

    Authentication mode 1.

    29

    access_model2

    Authentication mode 2. Enabling two-factor authentication will use the custom authorizer ID.

    30

    inner_time

    APIG internal processing duration, in seconds.

    31

    proxy_protocol_vni

    VPC endpoint virtual network ID.

    32

    proxy_protocol_vpce_id

    VPC endpoint ID.

    33

    proxy_protocol_addr

    Client IP address.

    34

    body_bytes_sent

    API request body size, in bytes.

    35

    api_name

    API name.

    36

    app_name

    Name of the app used by a requester for authentication.

    37

    provider_app_id

    App ID of an API.

    38

    provider_app_name

    App name of an API.

    39

    custom_data_log1

    Custom log field 1.

    40

    custom_data_log2

    Custom log field 2.

    41

    custom_data_log3

    Custom log field 3.

    42

    custom_data_log4

    Custom log field 4.

    43

    custom_data_log5

    Custom log field 5.

    44

    custom_data_log6

    Custom log field 6.

    45

    custom_data_log7

    Custom log field 7.

    46

    custom_data_log8

    Custom log field 8.

    47

    custom_data_log9

    Custom log field 9.

    48

    custom_data_log10

    Custom log field 10.

    49

    response_source

    Response source. Options:

    • local: APIG
    • remote: backend service

    50

    gzip_ratio

    Ratio of the original response body size to the compressed response body size.

    51

    upstream_scheme

    Backend protocol type.

    52

    group_id

    Group ID.

    53

    apig_err_code

    Gateway error code.

    54

    function_urn

    Function URN.

    55

    cache_status

    Indicates whether the request hits the cache.

    • MISS: No response cache is available. This value is usually used when an API is requested for the first time.
    • BYPASS: The request bypasses the cache and is directly forwarded to the upstream server.
    • STALE: The response in the cache has expired and a new response needs to be obtained from the upstream server.
    • HIT: The response is provided from the cache, not obtained from the upstream server in real time.

    56

    authorizer_downgrade

    Indicates the downgrade flag after the Relaxed Mode is enabled for custom authorizer.

    • 1: Only the frontend custom authorizer is downgraded.
    • 2: Only the backend custom authorizer is downgraded.
    • 3: Both frontend and backend custom authorizers are downgraded.
    • -: No downgrade is performed.

    57

    x_apm_version

    Tracing version.

    58

    x_apm_trace_id

    Unique global trace ID of a request.

    59

    x_apm_parent_span_id

    Parent span ID of the request.

    60

    x_apm_trace_flags

    Indicates whether to enable sampling. 01: enabled; 02: disabled.

    61

    x_apm_span_id

    Span ID of the request.