mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-14 01:02:32 +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:
@@ -1055,6 +1055,45 @@ definitions:
|
||||
tokens:
|
||||
type: integer
|
||||
type: object
|
||||
internal_api.TrafficBucket:
|
||||
properties:
|
||||
breakdown:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/internal_api.TrafficMetrics'
|
||||
type: object
|
||||
time:
|
||||
type: string
|
||||
timestamp:
|
||||
type: integer
|
||||
total:
|
||||
$ref: '#/definitions/internal_api.TrafficMetrics'
|
||||
type: object
|
||||
internal_api.TrafficChartResponse:
|
||||
properties:
|
||||
buckets:
|
||||
items:
|
||||
$ref: '#/definitions/internal_api.TrafficBucket'
|
||||
type: array
|
||||
granularity:
|
||||
type: string
|
||||
models:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
since:
|
||||
type: integer
|
||||
until:
|
||||
type: integer
|
||||
type: object
|
||||
internal_api.TrafficMetrics:
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
tokens_in:
|
||||
type: integer
|
||||
tokens_out:
|
||||
type: integer
|
||||
type: object
|
||||
internal_api.UpdateAccessRequest:
|
||||
properties:
|
||||
default_namespace:
|
||||
@@ -2333,6 +2372,50 @@ paths:
|
||||
summary: Log stats (admin)
|
||||
tags:
|
||||
- admin
|
||||
/admin/logs/stats/traffic-chart:
|
||||
get:
|
||||
description: Get time × model aggregated data for stacked traffic charts. Returns
|
||||
time buckets with per-model breakdown.
|
||||
parameters:
|
||||
- description: 'Time granularity: hour (default) or minute'
|
||||
enum:
|
||||
- hour
|
||||
- minute
|
||||
in: query
|
||||
name: granularity
|
||||
type: string
|
||||
- description: Start time (unix seconds), defaults to 24h ago
|
||||
in: query
|
||||
name: since
|
||||
type: integer
|
||||
- description: End time (unix seconds), defaults to now
|
||||
in: query
|
||||
name: until
|
||||
type: integer
|
||||
- description: Number of top models to return (1-20), defaults to 5
|
||||
in: query
|
||||
name: top_n
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
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'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: Traffic chart data (admin)
|
||||
tags:
|
||||
- admin
|
||||
/admin/logs/webhook:
|
||||
get:
|
||||
description: Returns current webhook notification config
|
||||
|
||||
Reference in New Issue
Block a user