Documentation
¶
Index ¶
- type CircuitBreakerInfo
- type Dashboard
- func (a *Dashboard) HandleWebSocket(c *gin.Context)
- func (a *Dashboard) IsPrometheusAvailable() bool
- func (a *Dashboard) QueryCircuitBreakers(c *gin.Context)
- func (a *Dashboard) QueryModelRanking(c *gin.Context)
- func (a *Dashboard) QueryOverview(c *gin.Context)
- func (a *Dashboard) QueryQPS(c *gin.Context)
- func (a *Dashboard) QueryTrends(c *gin.Context)
- func (a *Dashboard) SyncRedis(c *gin.Context)
- type ModelRankingItem
- type OverviewResponse
- type TrendsResponse
- type TrendsSeries
- type WSConfigMsg
- type WSDashboardPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreakerInfo ¶
type CircuitBreakerInfo struct {
ID string `json:"id"`
Type string `json:"type"` // "endpoint" 或 "service"
Name string `json:"name"` // 显示名称
ModelID string `json:"model_id"` // 关联模型 ID
ModelName string `json:"model_name"` // 关联模型名称
ProviderID string `json:"provider_id"` // 关联供应商 ID
ProviderName string `json:"provider_name"` // 关联供应商名称
URL string `json:"url"` // 关联的 URL 地址
}
type Dashboard ¶
type Dashboard struct {
DB *gorm.DB
RedisClient *redis.Client
RedisSync *biz.ConfigRedisSync
// contains filtered or unexported fields
}
func (*Dashboard) HandleWebSocket ¶
HandleWebSocket upgrades the HTTP request to WebSocket and pushes dashboard metrics
func (*Dashboard) IsPrometheusAvailable ¶
IsPrometheusAvailable 导出的版本,用于测试
func (*Dashboard) QueryCircuitBreakers ¶
@Tags DashboardAPI @Security ApiKeyAuth @Summary Query all endpoints that are currently in Open/Isolated state from Redis @Success 200 {object} util.ResponseResult{data=[]CircuitBreakerInfo} @Router /api/v1/dashboard/circuit-breakers [get]
func (*Dashboard) QueryModelRanking ¶
@Tags DashboardAPI @Security ApiKeyAuth @Summary Query model usage ranking with detailed metrics @Param sort_by query string false "Sort by: request_count, avg_latency, avg_ttft, tokens, cost, success_rate (default: request_count)" @Param limit query int false "Limit results (default: 10)" @Success 200 {object} util.ResponseResult{data=[]ModelRankingItem} @Router /api/v1/dashboard/model-ranking [get]
func (*Dashboard) QueryOverview ¶
@Tags DashboardAPI @Security ApiKeyAuth @Summary Query dashboard overview metrics (QPS, daily stats, latency, circuit breakers) @Success 200 {object} util.ResponseResult{data=OverviewResponse} @Router /api/v1/dashboard/overview [get]
func (*Dashboard) QueryQPS ¶
@Tags DashboardAPI @Security ApiKeyAuth @Summary Query real-time gateway QPS from Prometheus @Success 200 {object} util.ResponseResult{data=float64} @Router /api/v1/dashboard/qps [get]
func (*Dashboard) QueryTrends ¶
@Tags DashboardAPI @Security ApiKeyAuth @Summary Query bucketed gateway traffic success/failure trends @Param group_by query string false "Group by: model, provider, tenant, endpoint (default: global)" @Param time_range query string false "Time range: 1h, 6h, 24h, 7d, today (default: 1h)" @Success 200 {object} util.ResponseResult{data=TrendsResponse} @Router /api/v1/dashboard/trends [get]
type ModelRankingItem ¶
type ModelRankingItem struct {
ModelID string `json:"model_id"`
ModelCode string `json:"model_code"`
ModelName string `json:"model_name"`
RequestCount int64 `json:"request_count"`
SuccessCount int64 `json:"success_count"`
FailCount int64 `json:"fail_count"`
SuccessRate float64 `json:"success_rate"`
AvgLatencyMs float64 `json:"avg_latency_ms"`
P50LatencyMs float64 `json:"p50_latency_ms"`
P95LatencyMs float64 `json:"p95_latency_ms"`
P99LatencyMs float64 `json:"p99_latency_ms"`
AvgTTFTMs float64 `json:"avg_ttft_ms"`
P50TTFTMs float64 `json:"p50_ttft_ms"`
P95TTFTMs float64 `json:"p95_ttft_ms"`
P99TTFTMs float64 `json:"p99_ttft_ms"`
TotalTokens int64 `json:"total_tokens"`
TotalCost float64 `json:"total_cost"`
}
type OverviewResponse ¶
type OverviewResponse struct {
QPS float64 `json:"qps"`
DailyRequests int64 `json:"daily_requests"`
DailyPromptTokens int64 `json:"daily_prompt_tokens"`
DailyCompletionTokens int64 `json:"daily_completion_tokens"`
DailyCachedTokens int64 `json:"daily_cached_tokens"`
DailyCacheCreationTokens int64 `json:"daily_cache_creation_tokens"`
DailyCost float64 `json:"daily_cost"`
AvgLatencyMs float64 `json:"avg_latency_ms"`
AvgTTFTMs float64 `json:"avg_ttft_ms"`
ActiveCircuitBreakers []CircuitBreakerInfo `json:"active_circuit_breakers"`
}
type TrendsResponse ¶
type TrendsResponse struct {
Times []string `json:"times"`
Series []TrendsSeries `json:"series"`
}
type TrendsSeries ¶
type WSConfigMsg ¶
type WSConfigMsg struct {
TrendsTimeRange string `json:"trends_time_range"`
TrendsGroupBy string `json:"trends_group_by"`
ModelRankingSortBy string `json:"model_ranking_sort_by"`
ModelRankingTimeRange string `json:"model_ranking_time_range"`
}
WSConfigMsg represents the configuration parameters sent by the client
type WSDashboardPayload ¶
type WSDashboardPayload struct {
Overview *OverviewResponse `json:"overview"`
Trends *TrendsResponse `json:"trends"`
ModelRanking []ModelRankingItem `json:"model_ranking"`
}
WSDashboardPayload represents the unified push data payload