Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorBundles ¶
type ErrorBundles struct {
ByStage []dao.ErrBucket `json:"by_stage"`
ByChannel []dao.ErrBucket `json:"by_channel"`
}
ErrorBundles 是 monitoring 页底部失败分布的两个维度 (stage / channel)。
type Handler ¶
type Handler struct{}
Handler 是 /v1/monitoring/* 端点的容器。 当前仅承载 Insights;后续若新增 monitoring 子端点 (alerts、heartbeat 等), 都挂在同一个 Handler 上,便于路由聚合。
func (*Handler) Insights ¶
func (h *Handler) Insights(c *app.Context, req InsightsRequest) (InsightsResponse, error)
Insights 是 monitoring 页的总入口。
全 admin-only:user scope 直接 403 (monitoring 是运维向工具, 一般用户不关心 channel/agent 健康度)。
各子查询失败不阻断主响应:monitoring 是 best-effort 聚合面板, 单项失败时退化为零值/空数组。这一行为与 stats.Dashboard 一致。
唯一会阻断响应的是窗口校验和 KPI 环聚合错误 (后者依赖 DashboardKpis, 失败说明 DB 出问题,值得 500)。
type InsightsRequest ¶
type InsightsRequest struct {
Start int64 `form:"start"`
End int64 `form:"end"`
Gran string `form:"gran"`
}
InsightsRequest 是 /v1/monitoring/insights 入参。 start/end 为 unix 秒, end 缺省 now, start 缺省 end-86400; gran 缺省 "day"。窗口超限会被 ObsRange.Validate 拦下。
type InsightsResponse ¶
type InsightsResponse struct {
KpiRings KpiRings `json:"kpi_rings"`
Channels []dao.ChannelMetric `json:"channels"`
Agents []dao.AgentMetric `json:"agents"`
Errors ErrorBundles `json:"errors"`
}
InsightsResponse 是 /v1/monitoring/insights 返回的整体结构。
KpiRings 顶部的 5 个圆环 (success/cache/agents/tps/error); Channels/Agents 是两个 entity 维度的明细列表; Errors 是 stage + channel 双维度失败分布。
整页 admin-only;user scope 在 handler 层直接 403。
type KpiRing ¶
type KpiRing struct {
Ratio float64 `json:"ratio"`
Value any `json:"value"`
Sub string `json:"sub"`
WarnAbove *float64 `json:"warn_above,omitempty"`
}
KpiRing 是单个环形 KPI 卡片的统一形态。
Value 是 any 因为不同卡片含义不同:
success/cache/tps/error → 数字 (int64 / float64) agents → 形如 "3/4" 的字符串 (online/total)
WarnAbove 仅 error 卡片填充,前端高于阈值时变红。