Updated on 2022-12-05 GMT+08:00

Querying API Metric Statistics

Function

This API is used to query API statistics of an instance.

Constraints

If the invoking times out or the error message "request statistics error" is returned, switch to another mode or shorten the statistics collection duration.

URI

GET /v2/{project_id}/apic/instances/{instance_id}/statistics/api

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Appendix > Obtaining a Project ID in the ROMA Connect API Reference.

instance_id

Yes

String

Instance ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

mode

No

String

Query mode.

  • ALL: query in all applications under an instance. The master account permission is required.

  • APP: query in a specified integration application

  • API: query in a specified API

  • INSTANCE (default value): query in an instance

Note: When mode is set to APP or ALL, the cycle, api_id, group_id, provider, register_time, and status fields are not returned in the interface response.

Default: INSTANCE

roma_app_id

No

String

Integration application ID. This parameter is mandatory when mode is set to APP.

api_id

No

String

API ID. This parameter is mandatory when mode is set to API.

cycle

No

String

Measurement period.

  • minute: minute

  • hour: hour

  • day: day

Default: minute

start_time

No

String

Start time, for example, 2020-06-18 10:00:01.

end_time

No

String

End time, for example, 2020-06-18 23:00:00.

duration

No

String

Statistics duration format: Integer + Unit (m or h). m: minute; h: hour. The combination of hour and minute is supported. For example, 1h or 2h45m.

  • If start_time and end_time are given, [start_time, end_time] is queried.

  • If start_time does not exist, end_time and duration exist and are valid, the query range is [end_time - duration, end_time].

  • If neither start_time nor end_time exists, duration exists and is valid, and end_time is set to now, the query range is [end_time - duration, end_time].

  • If start_time, end_time, nor duration exists, the error message "missing time range parameters" is displayed.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

code

String

Response code.

start_time

Integer

Timestamp (UTC) of the start time.

end_time

Integer

Timestamp (UTC) of the end time.

list

Array of StatisticsAPI objects

Statistic data.

Table 5 StatisticsAPI

Parameter

Type

Description

max_latency

Integer

Maximum latency.

avg_latency

Number

Average latency.

req_count

Integer

Total number of requests.

req_count2xx

Integer

Total number of 2xx response codes.

req_count4xx

Integer

Total number of 4xx response codes.

req_count5xx

Integer

Total number of 5xx response codes.

req_count_error

Integer

Number of errors.

max_inner_latency

Integer

Maximum gateway latency.

avg_inner_latency

Number

Average gateway latency.

max_backend_latency

Integer

Maximum backend latency.

avg_backend_latency

Number

Average backend latency.

output_throughput

Integer

Downstream throughput (bytes).

input_throughput

Integer

Upstream throughput (bytes).

current_minute

Long

Timestamp (UTC) of API access.

cycle

String

Measurement period.

api_id

String

API ID.

group_id

String

API group ID.

provider

String

API provider.

req_time

String

Request time.

register_time

String

Recording time.

status

Integer

Status.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 403

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 404

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

None

Example Responses

Status code: 200

OK

{
  "code" : "APIG.0000",
  "start_time" : 1599400383,
  "end_time" : 1599616383,
  "list" : [ {
    "max_latency" : 0,
    "avg_latency" : 0,
    "max_inner_latency" : 0,
    "avg_inner_latency" : 0,
    "max_backend_latency" : 0,
    "avg_backend_latency" : 0,
    "req_count" : 5,
    "req_count2xx" : 0,
    "req_count4xx" : 0,
    "req_count5xx" : 5,
    "req_count_error" : 5,
    "output_throughput" : 1695,
    "input_throughput" : 2990,
    "current_minute" : 1599552000,
    "req_time" : "2020-09-08 16:00:00",
    "cycle" : "HOUR",
    "api_id" : "85deba41aae24839b14cdc03780e8bb6",
    "group_id" : "22ea1e9d294e4349940b6452a7fd2207",
    "provider" : "2cb5460f617c4822835e38f0966d8b93",
    "register_time" : "2020-09-08 17:22:22"
  } ]
}

Status code: 400

Bad Request

{
  "error_code" : "APIG.2012",
  "error_msg" : "Invalid parameter value,parameterName:api_id. Please refer to the support documentation"
}

Status code: 401

Unauthorized

{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

Forbidden

{
  "error_code" : "APIG.1005",
  "error_msg" : "No permissions to request this method"
}

Status code: 404

Not Found

{
  "error_code" : "APIG.3002",
  "error_msg" : "API 39bce6d25a3f470e8cf7b2c97174f7d9 does not exist"
}

Status code: 500

Internal Server Error

{
  "error_code" : "APIG.9999",
  "error_msg" : "System error"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.