API7 Docs

Get Usage Metrics

GET /environments/{env_id}/usage_metrics

GET /environments/{env_id}/usage_metrics

Interactive request editor loads with JavaScript.

Authorization

BearerAdminToken
AuthorizationBearer <token>

Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.

In: header

Path Parameters

env_id*string

Environment ID.

Formatuuid

Query Parameters

from*string

Inclusive lower bound on occurred_at, RFC 3339.

Formatdate-time
to*string

Exclusive upper bound on occurred_at, RFC 3339. Must be strictly after from.

Formatdate-time

Response 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
}
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 on occurred_at, RFC 3339.

  • to (query, string, required): Exclusive upper bound on occurred_at, RFC 3339. Must be strictly after from.

Responses

  • 200: OK

  • request_count (integer, required):

  • success_count (integer, required): Requests that ended successfully. request_count minus 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. 0 means the window held no such request.

  • latency_p99_ms (number, required): 99th percentile over the same sample as latency_p50_ms. 0 means 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 to GET /environments/{env_id}/usage_metrics, response 400 above.

  • 404: Resource not found. Response fields (application/json): identical to GET /environments/{env_id}/usage_metrics, response 400 above.

  • 503: The deployment is not configured to serve this data. Response fields (application/json): identical to GET /environments/{env_id}/usage_metrics, response 400 above.

cURL

curl -X GET '$AISIX_CP/environments/{env_id}/usage_metrics' -H 'Authorization: Bearer $AISIX_TOKEN'