Get Usage Metrics
GET /environments/{env_id}/usage_metrics
GET /environments/{env_id}/usage_metricsInteractive request editor loads with JavaScript.
Authorization
BearerAdminToken Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.
In: header
Path Parameters
Environment ID.
uuidQuery Parameters
Inclusive lower bound on occurred_at, RFC 3339.
date-timeExclusive upper bound on occurred_at, RFC 3339. Must be
strictly after from.
date-timeResponse Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "$AISIX_CP/environments/$ENV_ID/usage_metrics?from=2026-08-01T00%3A00%3A00Z&to=2026-08-08T00%3A00%3A00Z" \ -H "Authorization: Bearer $AISIX_TOKEN"OK
{
"request_count": 0,
"success_count": 0,
"estimated_request_count": 0,
"latency_p50_ms": 0.1,
"latency_p99_ms": 0.1
}Request body or parameters failed validation.
{
"error": {
"code": "string",
"message": "string"
}
}Missing or invalid bearer.
{
"error": {
"code": "UNAUTHENTICATED",
"message": "no org context"
}
}Resource not found.
{
"error": {
"code": "NOT_FOUND",
"message": "provider key not found"
}
}The deployment is not configured to serve this data.
{
"error": {
"code": "DPMGR_UNAVAILABLE",
"message": "dp-manager node store not configured on this cp-api"
}
}Complete operation details and schema variants
GET /environments/{env_id}/usage_metrics
Get Usage Metrics
Request-level counters and exact latency percentiles for the window.
These are the figures to use for success rate and latency over a
whole window: usage_summary also counts distinct requests, but
it does so per bucket, so a request whose attempts straddle a
bucket boundary is counted in both and summing buckets
over-counts. Latency is what the caller waited for, not
per-attempt upstream time.
Parameters
-
env_id(path, string, required): Environment ID. -
from(query, string, required): Inclusive lower bound onoccurred_at, RFC 3339. -
to(query, string, required): Exclusive upper bound onoccurred_at, RFC 3339. Must be strictly afterfrom.
Responses
-
200: OK -
request_count(integer, required): -
success_count(integer, required): Requests that ended successfully.request_countminus this is the error count the window's error rate is built from. -
estimated_request_count(integer, required): Requests whose token counts the gateway estimated locally because the upstream reported none. -
latency_p50_ms(number, required): Median of what callers waited, in milliseconds. Computed over SUCCESSFUL requests that carry a measured caller latency, so failures and requests rejected before dispatch are excluded rather than counted as slow.0means the window held no such request. -
latency_p99_ms(number, required): 99th percentile over the same sample aslatency_p50_ms.0means the window held no measured successful request. -
400: Request body or parameters failed validation. -
error(object, required): Error details. -
error.code(string, required): Machine-readable identifier. Examples:UNAUTHENTICATED,INVALID_REQUEST,MASTER_KEY_UNSET,INTERNAL. -
error.message(string, required): Human-readable explanation; safe to surface to operators. -
401: Missing or invalid bearer. Response fields (application/json): identical toGET /environments/{env_id}/usage_metrics, response 400 above. -
404: Resource not found. Response fields (application/json): identical toGET /environments/{env_id}/usage_metrics, response 400 above. -
503: The deployment is not configured to serve this data. Response fields (application/json): identical toGET /environments/{env_id}/usage_metrics, response 400 above.
cURL
curl -X GET '$AISIX_CP/environments/{env_id}/usage_metrics' -H 'Authorization: Bearer $AISIX_TOKEN'