All Products
Search
Document Center

API Gateway:QueryRequestLogs

Last Updated:Mar 16, 2026

Queries the request logs of a user.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

apigateway:QueryRequestLogs

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RequestLogId

string

Yes

The ID of the request log.

95657ED9-2F6F-426F-BD99-79C8********

Response elements

Element

Type

Description

Example

object

The returned data.

RequestId

string

The ID of the request.

CE5722A6-AE78-4741-A9B0-6C81********

RequestLogs

object

RequestLog

array<object>

The request logs.

object

The request log.

ApiId

string

The API ID.

4b83229ebcab4ecd88956fb3********

ApiName

string

The API name.

ApiName

ConsumerAppKey

string

The App Key that is used by the caller.

20412****

TotalLatency

string

The total time consumed by the request. Unit: milliseconds.

1345

HttpMethod

string

The HTTP method that is used to send the request.

POST

Domain

string

The requested domain name in the request.

360bdd88695c48ae8085c7f2********-ap-southeast-1.alicloudapi.com

ErrorMessage

string

The error message returned if the call fails.

Backend service connect failed `Timeout connecting to [/1XX.20.0.XX:8080]`

ConsumerAppId

string

The application ID that is used by the caller.

11096****

InstanceId

string

The ID of the API Gateway instance to which the API belongs.

apigateway-bj-ab2b********

ClientNonce

string

The X-Ca-Nonce header included in the request from the client.

d43df9db-3b05-4cd6-888a-1c0b********

RequestSize

string

The size of the request. Unit: bytes.

1923

StageId

string

The ID of the API environment.

8a305b7f10334052a52d9156********

StageName

string

The name of the API environment.

RELEASE

HttpPath

string

The path of the request.

/testPath

RequestId

string

The request ID.

95657ED9-2F6F-426F-BD99-79C8********

GroupId

string

The ID of the API group to which the API belongs.

dc024277fe6c4cada79ba0bd6********

GroupName

string

The name of the API group to which the API belongs.

GroupName

ErrorCode

string

The error code that is returned.

X500ER

ResponseSize

string

The size of returned data. Unit: bytes.

23441

Region

string

The region in which the instance resides.

cn-hangzhou

StatusCode

string

The status code returned.

200

ClientIp

string

The IP address of the client that sends the request.

21.237.XXX.XXX

ServiceLatency

string

The total time consumed to access the backend resources. The total time includes the time consumed to request a connection to the resources, the time consumed to establish the connection, and the time consumed to call the backend service. Unit: milliseconds.

324

RequestTime

string

The request time, in UTC.

2022-10-29T03:59:59Z

Exception

string

The specific error message returned by the backend service.

error msg

CustomTraceId

string

The custom trace ID.

95657ED9-2F6F-426F-BD99-79C8********

JwtClaims

string

The JSON web token (JWT) claims. The claims can be configured at the group level.

{}

RequestProtocol

string

The protocol used by the client to send the request. Valid values: HTTP, HTTPS, and WS.

HTTP

RequestHeaders

string

The request headers.

content-type: application/x-www-form-urlencoded

RequestQueryString

string

The query string for the request.

username=name

RequestBody

string

The request body. A request body cannot exceed 1,024 bytes in size.

param=paramName

ResponseHeaders

string

The headers in the API response.

content-type: application/x-www-form-urlencoded

ResponseBody

string

The response body. A response body cannot exceed 1,024 bytes in size.

param=paramName

plugin

string

The plug-in hit by the request and the relevant context.

[]

InitialRequestId

string

The initial request ID when API Gateway calls an API. For example, if API-1 calls API-2, the initialRequestId parameter in the log of API-2 indicates the ID of the request from API-1.

95657ED9-2F6F-426F-BD99-79C8********

AppName

string

The application name.

VIPROOM_VIPROOM

FrontRequestStart

integer

The time when API Gateway started to receive the request.

1731487224968

FrontRequestEnd

integer

The time when API Gateway finished receiving the request.

1731487224968

BackendRequestStart

integer

The time when API Gateway started to forward the request to the backend service.

1731487224969

BackendRequestEnd

integer

The time when API Gateway finished forwarding the request to the backend service.

1731487224969

BackendResponseStart

integer

The time when API Gateway started to receive the response from the backend service.

1731487224989

BackendResponseEnd

integer

The time when API Gateway finished receiving the response from the backend service.

1731487224989

FrontResponseStart

integer

The time when API Gateway started to forward the response to the client.

1731487224989

FrontResponseEnd

integer

The time when API Gateway finished forwarding the response to the client.

1731487224989

Examples

Success response

JSON format

{
  "RequestId": "CE5722A6-AE78-4741-A9B0-6C81********",
  "RequestLogs": {
    "RequestLog": [
      {
        "ApiId": "4b83229ebcab4ecd88956fb3********",
        "ApiName": "ApiName",
        "ConsumerAppKey": "20412****",
        "TotalLatency": "1345",
        "HttpMethod": "POST",
        "Domain": "360bdd88695c48ae8085c7f2********-ap-southeast-1.alicloudapi.com",
        "ErrorMessage": "Backend service connect failed `Timeout connecting to [/1XX.20.0.XX:8080]`",
        "ConsumerAppId": "11096****",
        "InstanceId": "apigateway-bj-ab2b********",
        "ClientNonce": "d43df9db-3b05-4cd6-888a-1c0b********",
        "RequestSize": "1923",
        "StageId": "8a305b7f10334052a52d9156********",
        "StageName": "RELEASE",
        "HttpPath": "/testPath",
        "RequestId": "95657ED9-2F6F-426F-BD99-79C8********",
        "GroupId": "dc024277fe6c4cada79ba0bd6********",
        "GroupName": "GroupName",
        "ErrorCode": "X500ER",
        "ResponseSize": "23441",
        "Region": "cn-hangzhou",
        "StatusCode": "200",
        "ClientIp": "21.237.XXX.XXX",
        "ServiceLatency": "324",
        "RequestTime": "2022-10-29T03:59:59Z",
        "Exception": "error msg",
        "CustomTraceId": "95657ED9-2F6F-426F-BD99-79C8********",
        "JwtClaims": "{}",
        "RequestProtocol": "HTTP",
        "RequestHeaders": "content-type: application/x-www-form-urlencoded",
        "RequestQueryString": "username=name",
        "RequestBody": "param=paramName",
        "ResponseHeaders": "content-type: application/x-www-form-urlencoded\n",
        "ResponseBody": "param=paramName\n",
        "plugin": "[]",
        "InitialRequestId": "95657ED9-2F6F-426F-BD99-79C8********",
        "AppName": "VIPROOM_VIPROOM",
        "FrontRequestStart": 1731487224968,
        "FrontRequestEnd": 1731487224968,
        "BackendRequestStart": 1731487224969,
        "BackendRequestEnd": 1731487224969,
        "BackendResponseStart": 1731487224989,
        "BackendResponseEnd": 1731487224989,
        "FrontResponseStart": 1731487224989,
        "FrontResponseEnd": 1731487224989
      }
    ]
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.