mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(api): add admin traffic chart statistics endpoint
Add new endpoint GET /admin/logs/stats/traffic-chart to provide aggregated traffic metrics grouped by time and model. Features include: - Time granularity selection (hour/minute) - Top-N model breakdown with "other" aggregation - Metrics for request counts and token usage Includes generated Swagger documentation.
This commit is contained in:
@@ -1604,6 +1604,73 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/logs/stats/traffic-chart": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Get time × model aggregated data for stacked traffic charts. Returns time buckets with per-model breakdown.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"summary": "Traffic chart data (admin)",
|
||||
"parameters": [
|
||||
{
|
||||
"enum": [
|
||||
"hour",
|
||||
"minute"
|
||||
],
|
||||
"type": "string",
|
||||
"description": "Time granularity: hour (default) or minute",
|
||||
"name": "granularity",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Start time (unix seconds), defaults to 24h ago",
|
||||
"name": "since",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "End time (unix seconds), defaults to now",
|
||||
"name": "until",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Number of top models to return (1-20), defaults to 5",
|
||||
"name": "top_n",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/internal_api.TrafficChartResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gin.H"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gin.H"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admin/logs/webhook": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -5834,6 +5901,66 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"internal_api.TrafficBucket": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"breakdown": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/internal_api.TrafficMetrics"
|
||||
}
|
||||
},
|
||||
"time": {
|
||||
"type": "string"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"$ref": "#/definitions/internal_api.TrafficMetrics"
|
||||
}
|
||||
}
|
||||
},
|
||||
"internal_api.TrafficChartResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"buckets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/internal_api.TrafficBucket"
|
||||
}
|
||||
},
|
||||
"granularity": {
|
||||
"type": "string"
|
||||
},
|
||||
"models": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"since": {
|
||||
"type": "integer"
|
||||
},
|
||||
"until": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"internal_api.TrafficMetrics": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tokens_in": {
|
||||
"type": "integer"
|
||||
},
|
||||
"tokens_out": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"internal_api.UpdateAccessRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Reference in New Issue
Block a user