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 {
LogDatabaseReady func() bool
MonitoringDataFinder func(app.Application, context.Context) MonitoringDataFinder
}
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 健康度)。
日志库在前置检查或任一实际查询中失联时返回 503;其它单项错误保持 best-effort,退化为零值或空数组。
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 卡片填充,前端高于阈值时变红。
type KpiRings ¶
type KpiRings struct {
Success KpiRing `json:"success"`
Cache KpiRing `json:"cache"`
Agents KpiRing `json:"agents"`
TPS KpiRing `json:"tps"`
Error KpiRing `json:"error"`
}
KpiRings 是 5 个并列的环形 KPI 卡片。 字段名与前端组件直接对齐 (success/cache/agents/tps/error)。
type LogBacklog ¶ added in v0.0.16
type LogBacklog struct {
Pending int `json:"pending"`
Retry int `json:"retry"`
Inflight int `json:"inflight"`
Bytes uint64 `json:"bytes"`
OldestSeconds int64 `json:"oldest_seconds"`
Dropped uint64 `json:"dropped"`
LastError string `json:"last_error"`
SchemaReady bool `json:"schema_ready"`
}
func LogBacklogFrom ¶ added in v0.0.16
func LogBacklogFrom(status masterlogqueue.DeliveryStatus) LogBacklog
type MonitoringDataFinder ¶ added in v0.0.14
type MonitoringDataFinder interface {
ChannelMetrics(dao.ObsRange) ([]dao.ChannelMetric, error)
AgentMetrics(dao.ObsRange) ([]dao.AgentMetric, error)
ErrorDistribution(string, dao.ObsRange, dao.Scope) ([]dao.ErrBucket, error)
DashboardKpis(dao.ObsRange, dao.Scope, dao.ObsFilter) (dao.KpiBundle, error)
CacheSaving(dao.ObsRange, dao.Scope, dao.ObsFilter) (dao.CacheSaving, error)
}