Documentation
¶
Overview ¶
Package diagnostics provides the diagnostics workspace skeleton for error center, inspections, and diagnostic bundle tasks. diagnostics 包提供诊断中心骨架,用于承载错误中心、巡检与诊断任务。
Index ¶
- Constants
- Variables
- func BuildErrorFingerprint(message, evidence string) (fingerprint, normalized, exceptionClass, title string)
- func ExtractExceptionClass(value string) string
- type AutoPolicyChecker
- func (c *AutoPolicyChecker) CheckErrorSpikePolicies(ctx context.Context, clusterID uint, now time.Time) error
- func (c *AutoPolicyChecker) CheckJavaErrorTrigger(ctx context.Context, clusterID uint, exceptionClass string, ...) error
- func (c *AutoPolicyChecker) CheckPrometheusPolicies(ctx context.Context, clusterID uint, now time.Time) error
- func (c *AutoPolicyChecker) CheckScheduledPolicies(ctx context.Context, clusterID uint, now time.Time) error
- type ClusterInspectionFinding
- type ClusterInspectionFindingFilter
- type ClusterInspectionFindingInfo
- type ClusterInspectionReport
- type ClusterInspectionReportDetailData
- type ClusterInspectionReportFilter
- type ClusterInspectionReportInfo
- type ClusterInspectionReportsData
- type ClusterOption
- type CreateDiagnosticTaskRequest
- type CreateInspectionAutoPolicyRequest
- type DiagnosticExecutionRequest
- type DiagnosticHostDisplayContext
- type DiagnosticLanguage
- type DiagnosticLogEventType
- type DiagnosticLogLevel
- type DiagnosticLogMetadata
- type DiagnosticNodeExecution
- type DiagnosticPlanStep
- type DiagnosticStepCode
- type DiagnosticStepLog
- type DiagnosticTask
- type DiagnosticTaskEvent
- type DiagnosticTaskEventType
- type DiagnosticTaskListData
- type DiagnosticTaskListFilter
- type DiagnosticTaskLogFilter
- type DiagnosticTaskLogListData
- type DiagnosticTaskNodeScope
- type DiagnosticTaskNodeTarget
- type DiagnosticTaskNodeTargets
- type DiagnosticTaskOptions
- type DiagnosticTaskSourceRef
- type DiagnosticTaskSourceType
- type DiagnosticTaskStatus
- type DiagnosticTaskStep
- type DiagnosticTaskSummary
- type Handler
- func (h *Handler) CreateAutoPolicy(c *gin.Context)
- func (h *Handler) CreateDiagnosticTask(c *gin.Context)
- func (h *Handler) DeleteAutoPolicy(c *gin.Context)
- func (h *Handler) DownloadDiagnosticTaskBundle(c *gin.Context)
- func (h *Handler) GetAutoPolicy(c *gin.Context)
- func (h *Handler) GetDiagnosticTask(c *gin.Context)
- func (h *Handler) GetInspectionReportDetail(c *gin.Context)
- func (h *Handler) GetSeatunnelErrorGroupDetail(c *gin.Context)
- func (h *Handler) GetWorkspaceBootstrap(c *gin.Context)
- func (h *Handler) ListAutoPolicies(c *gin.Context)
- func (h *Handler) ListBuiltinConditionTemplates(c *gin.Context)
- func (h *Handler) ListDiagnosticTaskLogs(c *gin.Context)
- func (h *Handler) ListDiagnosticTaskSteps(c *gin.Context)
- func (h *Handler) ListDiagnosticTasks(c *gin.Context)
- func (h *Handler) ListInspectionReports(c *gin.Context)
- func (h *Handler) ListSeatunnelErrorEvents(c *gin.Context)
- func (h *Handler) ListSeatunnelErrorGroups(c *gin.Context)
- func (h *Handler) PreviewDiagnosticTaskFile(c *gin.Context)
- func (h *Handler) PreviewDiagnosticTaskHTML(c *gin.Context)
- func (h *Handler) SetAuditRepository(repo *audit.Repository)
- func (h *Handler) StartDiagnosticTask(c *gin.Context)
- func (h *Handler) StartInspection(c *gin.Context)
- func (h *Handler) StreamDiagnosticTaskEvents(c *gin.Context)
- func (h *Handler) UpdateAutoPolicy(c *gin.Context)
- type IngestSeatunnelErrorRequest
- type InspectionAutoPolicy
- type InspectionAutoPolicyInfo
- type InspectionAutoPolicyListData
- type InspectionConditionCategory
- type InspectionConditionItem
- type InspectionConditionItems
- type InspectionConditionTemplate
- type InspectionConditionTemplateCode
- type InspectionEvaluationResult
- type InspectionFindingSeverity
- type InspectionReportStatus
- type InspectionTriggerSource
- type Repository
- func (r *Repository) CreateAutoPolicy(ctx context.Context, policy *InspectionAutoPolicy) error
- func (r *Repository) CreateDiagnosticNodeExecutions(ctx context.Context, nodes []*DiagnosticNodeExecution) error
- func (r *Repository) CreateDiagnosticStepLog(ctx context.Context, log *DiagnosticStepLog) error
- func (r *Repository) CreateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
- func (r *Repository) CreateDiagnosticTaskSteps(ctx context.Context, steps []*DiagnosticTaskStep) error
- func (r *Repository) CreateErrorEvent(ctx context.Context, event *SeatunnelErrorEvent) error
- func (r *Repository) CreateErrorGroup(ctx context.Context, group *SeatunnelErrorGroup) error
- func (r *Repository) CreateInspectionFinding(ctx context.Context, finding *ClusterInspectionFinding) error
- func (r *Repository) CreateInspectionFindings(ctx context.Context, findings []*ClusterInspectionFinding) error
- func (r *Repository) CreateInspectionReport(ctx context.Context, report *ClusterInspectionReport) error
- func (r *Repository) DeleteAutoPolicy(ctx context.Context, id uint) error
- func (r *Repository) GetAutoPolicyByID(ctx context.Context, id uint) (*InspectionAutoPolicy, error)
- func (r *Repository) GetDiagnosticTaskByID(ctx context.Context, id uint) (*DiagnosticTask, error)
- func (r *Repository) GetDiagnosticTaskByIDForOwner(ctx context.Context, id, ownerUserID uint, includeAll bool) (*DiagnosticTask, error)
- func (r *Repository) GetErrorGroupByFingerprint(ctx context.Context, fingerprint string) (*SeatunnelErrorGroup, error)
- func (r *Repository) GetErrorGroupByID(ctx context.Context, id uint) (*SeatunnelErrorGroup, error)
- func (r *Repository) GetInspectionFindingByID(ctx context.Context, id uint) (*ClusterInspectionFinding, error)
- func (r *Repository) GetInspectionReportByID(ctx context.Context, id uint) (*ClusterInspectionReport, error)
- func (r *Repository) GetLastInspectionReportForCluster(ctx context.Context, clusterID uint) (*ClusterInspectionReport, error)
- func (r *Repository) GetLastInspectionReportForRequester(ctx context.Context, clusterID uint, requestedBy string) (*ClusterInspectionReport, error)
- func (r *Repository) GetLatestDiagnosticTaskByInspectionReportID(ctx context.Context, reportID uint) (*DiagnosticTask, error)
- func (r *Repository) GetLogCursor(ctx context.Context, agentID, installDir, role, sourceFile string) (*SeatunnelLogCursor, error)
- func (r *Repository) ListAutoPolicies(ctx context.Context, clusterID *uint, page, pageSize int) ([]*InspectionAutoPolicy, int64, error)
- func (r *Repository) ListDiagnosticNodeExecutions(ctx context.Context, taskID uint) ([]*DiagnosticNodeExecution, error)
- func (r *Repository) ListDiagnosticStepLogs(ctx context.Context, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
- func (r *Repository) ListDiagnosticTaskSteps(ctx context.Context, taskID uint) ([]*DiagnosticTaskStep, error)
- func (r *Repository) ListDiagnosticTaskStepsForOwner(ctx context.Context, taskID, ownerUserID uint, includeAll bool) ([]*DiagnosticTaskStep, error)
- func (r *Repository) ListDiagnosticTasks(ctx context.Context, filter *DiagnosticTaskListFilter) ([]*DiagnosticTaskSummary, int64, error)
- func (r *Repository) ListEnabledPoliciesForCluster(ctx context.Context, clusterID uint) ([]*InspectionAutoPolicy, error)
- func (r *Repository) ListErrorEvents(ctx context.Context, filter *SeatunnelErrorEventFilter) ([]*SeatunnelErrorEvent, int64, error)
- func (r *Repository) ListErrorGroups(ctx context.Context, filter *SeatunnelErrorGroupFilter) ([]*SeatunnelErrorGroup, int64, error)
- func (r *Repository) ListEventsByGroupID(ctx context.Context, filter *SeatunnelErrorEventFilter, limit int) ([]*SeatunnelErrorEvent, error)
- func (r *Repository) ListInspectionFindings(ctx context.Context, filter *ClusterInspectionFindingFilter) ([]*ClusterInspectionFinding, int64, error)
- func (r *Repository) ListInspectionFindingsByReportID(ctx context.Context, reportID uint) ([]*ClusterInspectionFinding, error)
- func (r *Repository) ListInspectionReports(ctx context.Context, filter *ClusterInspectionReportFilter) ([]*ClusterInspectionReport, int64, error)
- func (r *Repository) ListLogCursorsByAgent(ctx context.Context, agentID string) ([]*SeatunnelLogCursor, error)
- func (r *Repository) ListRecentErrorGroupBursts(ctx context.Context, clusterID uint, since time.Time, limit int) ([]*recentErrorGroupBurst, error)
- func (r *Repository) SkipPendingDiagnosticNodeExecutions(ctx context.Context, taskID uint, message string, completedAt time.Time) error
- func (r *Repository) Transaction(ctx context.Context, fn func(tx *Repository) error) error
- func (r *Repository) UpdateAutoPolicy(ctx context.Context, policy *InspectionAutoPolicy) error
- func (r *Repository) UpdateDiagnosticNodeExecution(ctx context.Context, node *DiagnosticNodeExecution) error
- func (r *Repository) UpdateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
- func (r *Repository) UpdateDiagnosticTaskFields(ctx context.Context, taskID uint, expected []DiagnosticTaskStatus, ...) (bool, error)
- func (r *Repository) UpdateDiagnosticTaskStep(ctx context.Context, step *DiagnosticTaskStep) error
- func (r *Repository) UpdateErrorGroup(ctx context.Context, group *SeatunnelErrorGroup) error
- func (r *Repository) UpdateInspectionReport(ctx context.Context, report *ClusterInspectionReport) error
- func (r *Repository) UpdateInspectionReportAutoTriggerReason(ctx context.Context, reportID uint, reason string) error
- func (r *Repository) UpsertLogCursor(ctx context.Context, cursor *SeatunnelLogCursor) error
- type Response
- type SeatunnelErrorEvent
- type SeatunnelErrorEventFilter
- type SeatunnelErrorEventInfo
- type SeatunnelErrorEventsData
- type SeatunnelErrorGroup
- type SeatunnelErrorGroupDetailData
- type SeatunnelErrorGroupFilter
- type SeatunnelErrorGroupInfo
- type SeatunnelErrorGroupsData
- type SeatunnelLogCursor
- type Service
- func (s *Service) AppendDiagnosticStepLog(ctx context.Context, log *DiagnosticStepLog) error
- func (s *Service) CreateAutoPolicy(ctx context.Context, userID uint, req *CreateInspectionAutoPolicyRequest) (*InspectionAutoPolicyInfo, error)
- func (s *Service) CreateDiagnosticTask(ctx context.Context, req *CreateDiagnosticTaskRequest, createdBy uint, ...) (*DiagnosticTask, error)
- func (s *Service) CreateDiagnosticTaskWithExecution(ctx context.Context, req *CreateDiagnosticTaskRequest, createdBy uint, ...) (*DiagnosticTask, error)
- func (s *Service) DeleteAutoPolicy(ctx context.Context, id uint) error
- func (s *Service) EvaluateInspectionFindings(ctx context.Context, clusterID uint, lookbackWindow time.Duration, ...) (*InspectionEvaluationResult, error)
- func (s *Service) GetAutoPolicy(ctx context.Context, id uint) (*InspectionAutoPolicyInfo, error)
- func (s *Service) GetDiagnosticTaskDetail(ctx context.Context, taskID uint) (*DiagnosticTask, error)
- func (s *Service) GetDiagnosticTaskForActor(ctx context.Context, actor executionapp.Actor, taskID uint) (*DiagnosticTask, error)
- func (s *Service) GetInspectionReportDetail(ctx context.Context, reportID uint) (*ClusterInspectionReportDetailData, error)
- func (s *Service) GetSeatunnelErrorGroupDetail(ctx context.Context, filter *SeatunnelErrorEventFilter, eventLimit int) (*SeatunnelErrorGroupDetailData, error)
- func (s *Service) GetWorkspaceBootstrap(ctx context.Context, req *WorkspaceBootstrapRequest) (*WorkspaceBootstrapData, error)
- func (s *Service) IngestSeatunnelError(ctx context.Context, req *IngestSeatunnelErrorRequest) error
- func (s *Service) ListAutoPolicies(ctx context.Context, clusterID *uint, page, pageSize int) (*InspectionAutoPolicyListData, error)
- func (s *Service) ListBuiltinConditionTemplates() []*InspectionConditionTemplate
- func (s *Service) ListDiagnosticNodeExecutions(ctx context.Context, taskID uint) ([]*DiagnosticNodeExecution, error)
- func (s *Service) ListDiagnosticStepLogs(ctx context.Context, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
- func (s *Service) ListDiagnosticStepLogsForActor(ctx context.Context, actor executionapp.Actor, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
- func (s *Service) ListDiagnosticTaskSteps(ctx context.Context, taskID uint) ([]*DiagnosticTaskStep, error)
- func (s *Service) ListDiagnosticTaskStepsForActor(ctx context.Context, actor executionapp.Actor, taskID uint) ([]*DiagnosticTaskStep, error)
- func (s *Service) ListDiagnosticTasks(ctx context.Context, filter *DiagnosticTaskListFilter) ([]*DiagnosticTaskSummary, int64, error)
- func (s *Service) ListDiagnosticTasksForActor(ctx context.Context, actor executionapp.Actor, ...) ([]*DiagnosticTaskSummary, int64, error)
- func (s *Service) ListInspectionReports(ctx context.Context, filter *ClusterInspectionReportFilter) (*ClusterInspectionReportsData, error)
- func (s *Service) ListLogCursorsByAgent(ctx context.Context, agentID string) ([]*SeatunnelLogCursor, error)
- func (s *Service) ListSeatunnelErrorEvents(ctx context.Context, filter *SeatunnelErrorEventFilter) (*SeatunnelErrorEventsData, error)
- func (s *Service) ListSeatunnelErrorGroups(ctx context.Context, filter *SeatunnelErrorGroupFilter) (*SeatunnelErrorGroupsData, error)
- func (s *Service) RequestCancel(ctx context.Context, item *executionapp.Execution, actor executionapp.Actor) (executionapp.CancelResult, error)
- func (s *Service) SetAgentCommandSender(sender diagnosticAgentCommandSender)
- func (s *Service) SetExecutionService(service *executionapp.Service)
- func (s *Service) SetHostReader(reader hostReader)
- func (s *Service) StartAutoPolicyRuntime(ctx context.Context)
- func (s *Service) StartDiagnosticTask(ctx context.Context, taskID uint) error
- func (s *Service) StartDiagnosticTaskForActor(ctx context.Context, actor executionapp.Actor, taskID uint) error
- func (s *Service) StartInspection(ctx context.Context, req *StartClusterInspectionRequest, ...) (*ClusterInspectionReportDetailData, error)
- func (s *Service) SubscribeDiagnosticTaskEvents(taskID uint) (<-chan DiagnosticTaskEvent, func())
- func (s *Service) UpdateAutoPolicy(ctx context.Context, id uint, req *UpdateInspectionAutoPolicyRequest) (*InspectionAutoPolicyInfo, error)
- func (s *Service) UpdateDiagnosticNodeExecution(ctx context.Context, node *DiagnosticNodeExecution) error
- func (s *Service) UpdateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
- func (s *Service) UpdateDiagnosticTaskStep(ctx context.Context, step *DiagnosticTaskStep) error
- type StartClusterInspectionRequest
- type UpdateInspectionAutoPolicyRequest
- type WorkspaceBootstrapData
- type WorkspaceBootstrapRequest
- type WorkspaceBoundary
- type WorkspaceContext
- type WorkspaceTab
- type WorkspaceTabKey
Constants ¶
const ( // DefaultFingerprintVersion is the fingerprint algorithm version for Seatunnel error grouping. // DefaultFingerprintVersion 表示 Seatunnel 错误分组当前使用的指纹算法版本。 DefaultFingerprintVersion = "v1" )
Variables ¶
var ( // ErrDiagnosticsRepositoryUnavailable 表示诊断持久层不可用。 ErrDiagnosticsRepositoryUnavailable = errors.New("diagnostics: repository unavailable") // ErrInvalidSeatunnelErrorRequest indicates the inbound seatunnel error request is invalid. // ErrInvalidSeatunnelErrorRequest 表示入站的 Seatunnel 错误请求非法。 ErrInvalidSeatunnelErrorRequest = errors.New("diagnostics: invalid seatunnel error request") // ErrSeatunnelErrorGroupNotFound indicates the error group does not exist. // ErrSeatunnelErrorGroupNotFound 表示错误组不存在。 ErrSeatunnelErrorGroupNotFound = errors.New("diagnostics: seatunnel error group not found") // ErrSeatunnelErrorEventNotFound indicates the error event does not exist. // ErrSeatunnelErrorEventNotFound 表示错误事件不存在。 ErrSeatunnelErrorEventNotFound = errors.New("diagnostics: seatunnel error event not found") // ErrSeatunnelLogCursorNotFound indicates the log cursor does not exist. // ErrSeatunnelLogCursorNotFound 表示日志游标不存在。 ErrSeatunnelLogCursorNotFound = errors.New("diagnostics: seatunnel log cursor not found") // ErrInvalidInspectionRequest indicates the inspection request is invalid. // ErrInvalidInspectionRequest 表示巡检请求非法。 ErrInvalidInspectionRequest = errors.New("diagnostics: invalid inspection request") // ErrInspectionReportNotFound indicates the inspection report does not exist. // ErrInspectionReportNotFound 表示巡检报告不存在。 ErrInspectionReportNotFound = errors.New("diagnostics: inspection report not found") // ErrInspectionFindingNotFound indicates the inspection finding does not exist. // ErrInspectionFindingNotFound 表示巡检发现项不存在。 ErrInspectionFindingNotFound = errors.New("diagnostics: inspection finding not found") // ErrDiagnosticTaskNotFound indicates the diagnostics task does not exist. // ErrDiagnosticTaskNotFound 表示诊断任务不存在。 ErrDiagnosticTaskNotFound = errors.New("diagnostics: diagnostic task not found") // ErrDiagnosticTaskStepNotFound indicates the diagnostics task step does not exist. // ErrDiagnosticTaskStepNotFound 表示诊断任务步骤不存在。 ErrDiagnosticTaskStepNotFound = errors.New("diagnostics: diagnostic task step not found") // ErrDiagnosticNodeExecutionNotFound indicates the diagnostics node execution does not exist. // ErrDiagnosticNodeExecutionNotFound 表示诊断任务节点执行不存在。 ErrDiagnosticNodeExecutionNotFound = errors.New("diagnostics: diagnostic node execution not found") // ErrInvalidDiagnosticTaskRequest indicates the diagnostics task request is invalid. // ErrInvalidDiagnosticTaskRequest 表示诊断任务请求非法。 ErrInvalidDiagnosticTaskRequest = errors.New("diagnostics: invalid diagnostic task request") // ErrDiagnosticTaskAlreadyFinished 表示终态诊断任务不能再次启动或改写。 // ErrDiagnosticTaskAlreadyFinished indicates that a terminal diagnostic task cannot be started or rewritten again. ErrDiagnosticTaskAlreadyFinished = errors.New("diagnostics: diagnostic task already finished") // ErrAutoPolicyNotFound indicates the auto-inspection policy does not exist. // ErrAutoPolicyNotFound 表示自动巡检策略不存在。 ErrAutoPolicyNotFound = errors.New("diagnostics: auto-policy not found") // ErrInvalidAutoPolicyRequest indicates the auto-policy request is invalid. // ErrInvalidAutoPolicyRequest 表示自动策略请求非法。 ErrInvalidAutoPolicyRequest = errors.New("diagnostics: invalid auto-policy request") )
var BuiltinConditionTemplates = []InspectionConditionTemplate{ { Code: ConditionCodeJavaOOM, Category: ConditionCategoryJavaError, Name: bilingualText("Java 内存溢出 (OOM)", "Java Out Of Memory (OOM)"), Description: bilingualText("exception_class 含 OutOfMemoryError 时立即触发巡检。", "Trigger inspection immediately when exception_class contains OutOfMemoryError."), ImmediateOnMatch: true, }, { Code: ConditionCodeJavaStackOverflow, Category: ConditionCategoryJavaError, Name: bilingualText("Java 栈溢出", "Java Stack Overflow"), Description: bilingualText("exception_class 含 StackOverflowError 时立即触发巡检。", "Trigger inspection immediately when exception_class contains StackOverflowError."), ImmediateOnMatch: true, }, { Code: ConditionCodeJavaMetaspace, Category: ConditionCategoryJavaError, Name: bilingualText("Metaspace 耗尽", "Metaspace Exhausted"), Description: bilingualText("exception_class 含 OutOfMemoryError 且 message 含 Metaspace 时立即触发巡检。", "Trigger inspection immediately when exception_class contains OutOfMemoryError and message contains Metaspace."), ImmediateOnMatch: true, }, { Code: ConditionCodePromGCFrequent, Category: ConditionCategoryPrometheus, Name: bilingualText("GC 频繁", "Frequent GC"), Description: bilingualText("当 GC 频繁相关指标对应的告警持续触发时,自动发起巡检。", "Trigger inspection when the alert for frequent GC keeps firing."), DefaultThreshold: 10, DefaultWindowMinutes: 5, }, { Code: ConditionCodePromHeapRising, Category: ConditionCategoryPrometheus, Name: bilingualText("堆内存持续上涨", "Heap Keeps Rising"), Description: bilingualText("当堆内存持续上涨相关告警触发时,自动发起巡检。", "Trigger inspection when the heap-rising alert is firing."), DefaultWindowMinutes: 15, }, { Code: ConditionCodePromHeapHigh, Category: ConditionCategoryPrometheus, Name: bilingualText("堆内存使用率高", "High Heap Usage"), Description: bilingualText("当堆内存使用率高相关告警触发时,自动发起巡检。", "Trigger inspection when the high heap usage alert is firing."), DefaultThreshold: 85, DefaultWindowMinutes: 10, }, { Code: ConditionCodePromCPUHigh, Category: ConditionCategoryPrometheus, Name: bilingualText("CPU 持续高负载", "Sustained High CPU"), Description: bilingualText("当 CPU 持续高负载相关告警触发时,自动发起巡检。", "Trigger inspection when the sustained high CPU alert is firing."), DefaultThreshold: 90, DefaultWindowMinutes: 10, }, { Code: ConditionCodeErrorSpike, Category: ConditionCategoryErrorRate, Name: bilingualText("错误频率激增", "Error Spike"), Description: bilingualText("M 分钟内错误数超过 N 条。", "Trigger when the error count exceeds N within M minutes."), DefaultThreshold: 50, DefaultWindowMinutes: 5, }, { Code: ConditionCodeNodeUnhealthy, Category: ConditionCategoryNodeUnhealthy, Name: bilingualText("节点持续异常", "Persistent Node Anomaly"), Description: bilingualText("N 个节点异常持续 M 分钟。", "Trigger when N nodes remain abnormal for M minutes."), DefaultThreshold: 1, DefaultWindowMinutes: 10, }, { Code: ConditionCodeAlertFiring, Category: ConditionCategoryAlertFiring, Name: bilingualText("告警规则触发", "Alert Firing"), Description: bilingualText("指定告警规则 firing 时触发巡检。", "Trigger inspection when the specified alert rule is firing."), }, { Code: ConditionCodeScheduled, Category: ConditionCategorySchedule, Name: bilingualText("定时巡检", "Scheduled Inspection"), Description: bilingualText("按 Cron 表达式定时触发巡检。", "Trigger inspection on a schedule defined by a cron expression."), DefaultCronExpr: "0 0 * * *", }, }
BuiltinConditionTemplates is the complete list of built-in auto-inspection condition templates. BuiltinConditionTemplates 是内置自动巡检条件模板完整列表。
Functions ¶
func BuildErrorFingerprint ¶
func BuildErrorFingerprint(message, evidence string) (fingerprint, normalized, exceptionClass, title string)
BuildErrorFingerprint normalizes a Seatunnel error sample into a stable fingerprint. BuildErrorFingerprint 将 Seatunnel 错误样本归一化为稳定指纹。
func ExtractExceptionClass ¶
ExtractExceptionClass extracts the first exception/error class from text. ExtractExceptionClass 从文本中提取第一个异常/错误类名。
Types ¶
type AutoPolicyChecker ¶
type AutoPolicyChecker struct {
// contains filtered or unexported fields
}
AutoPolicyChecker evaluates auto-inspection policies against incoming signals. AutoPolicyChecker 根据传入信号评估自动巡检策略。
func NewAutoPolicyChecker ¶
func NewAutoPolicyChecker(repo *Repository, service *Service) *AutoPolicyChecker
NewAutoPolicyChecker creates an auto-policy checker. NewAutoPolicyChecker 创建自动策略检查器。
func (*AutoPolicyChecker) CheckErrorSpikePolicies ¶
func (c *AutoPolicyChecker) CheckErrorSpikePolicies(ctx context.Context, clusterID uint, now time.Time) error
CheckErrorSpikePolicies evaluates error-spike policies against recent diagnostics error events. CheckErrorSpikePolicies 根据近期诊断错误事件评估错误频率激增策略。
func (*AutoPolicyChecker) CheckJavaErrorTrigger ¶
func (c *AutoPolicyChecker) CheckJavaErrorTrigger(ctx context.Context, clusterID uint, exceptionClass string, messageSnippet string) error
CheckJavaErrorTrigger checks whether a Java error event should trigger an auto-inspection. CheckJavaErrorTrigger 检查一条 Java 错误事件是否应触发自动巡检。
func (*AutoPolicyChecker) CheckPrometheusPolicies ¶
func (c *AutoPolicyChecker) CheckPrometheusPolicies(ctx context.Context, clusterID uint, now time.Time) error
CheckPrometheusPolicies evaluates metric-signal policies through unified alert instances. CheckPrometheusPolicies 通过统一告警实例评估指标信号类策略。
func (*AutoPolicyChecker) CheckScheduledPolicies ¶
func (c *AutoPolicyChecker) CheckScheduledPolicies(ctx context.Context, clusterID uint, now time.Time) error
CheckScheduledPolicies checks all enabled schedule-based policies for one cluster. CheckScheduledPolicies 检查单个集群的所有定时巡检策略。
type ClusterInspectionFinding ¶
type ClusterInspectionFinding struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ReportID uint `json:"report_id" gorm:"index;not null"`
ClusterID uint `json:"cluster_id" gorm:"index;not null"`
Severity InspectionFindingSeverity `json:"severity" gorm:"size:20;index;not null"`
Category string `json:"category" gorm:"size:64;index;not null"`
CheckCode string `json:"check_code" gorm:"size:100;index;not null"`
CheckName string `json:"check_name" gorm:"size:200"`
Summary string `json:"summary" gorm:"type:text"`
Recommendation string `json:"recommendation" gorm:"type:text"`
EvidenceSummary string `json:"evidence_summary" gorm:"type:text"`
RelatedNodeID uint `json:"related_node_id" gorm:"index"`
RelatedHostID uint `json:"related_host_id" gorm:"index"`
RelatedErrorGroupID uint `json:"related_error_group_id" gorm:"index"`
RelatedAlertID string `json:"related_alert_id" gorm:"size:120;index"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
ClusterInspectionFinding stores one structured finding within an inspection report. ClusterInspectionFinding 存储巡检报告中的一条结构化发现项。
func (ClusterInspectionFinding) TableName ¶
func (ClusterInspectionFinding) TableName() string
TableName specifies the table name for ClusterInspectionFinding. TableName 指定 ClusterInspectionFinding 的表名。
func (*ClusterInspectionFinding) ToInfo ¶
func (f *ClusterInspectionFinding) ToInfo(display *DiagnosticHostDisplayContext) *ClusterInspectionFindingInfo
ToInfo converts one persisted inspection finding into API view model. ToInfo 将巡检发现项转换为 API 视图模型。
type ClusterInspectionFindingFilter ¶
type ClusterInspectionFindingFilter struct {
ReportID uint `json:"report_id"`
ClusterID uint `json:"cluster_id"`
Severity InspectionFindingSeverity `json:"severity"`
Category string `json:"category"`
RelatedNodeID uint `json:"related_node_id"`
RelatedHostID uint `json:"related_host_id"`
RelatedErrorGroupID uint `json:"related_error_group_id"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ClusterInspectionFindingFilter defines list filters for inspection findings. ClusterInspectionFindingFilter 定义巡检发现项列表过滤条件。
type ClusterInspectionFindingInfo ¶
type ClusterInspectionFindingInfo struct {
ID uint `json:"id"`
ReportID uint `json:"report_id"`
ClusterID uint `json:"cluster_id"`
Severity InspectionFindingSeverity `json:"severity"`
Category string `json:"category"`
CheckCode string `json:"check_code"`
CheckName string `json:"check_name"`
Summary string `json:"summary"`
Recommendation string `json:"recommendation"`
EvidenceSummary string `json:"evidence_summary"`
RelatedNodeID uint `json:"related_node_id"`
RelatedHostID uint `json:"related_host_id"`
RelatedHostName string `json:"related_host_name"`
RelatedHostIP string `json:"related_host_ip"`
RelatedErrorGroupID uint `json:"related_error_group_id"`
RelatedAlertID string `json:"related_alert_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ClusterInspectionFindingInfo is the API view model for one inspection finding. ClusterInspectionFindingInfo 是巡检发现项的 API 视图模型。
type ClusterInspectionReport ¶
type ClusterInspectionReport struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ClusterID uint `json:"cluster_id" gorm:"index;not null"`
Status InspectionReportStatus `json:"status" gorm:"size:20;index;not null"`
TriggerSource InspectionTriggerSource `json:"trigger_source" gorm:"size:32;index;not null"`
LookbackMinutes int `json:"lookback_minutes" gorm:"default:30"`
ErrorThreshold int `json:"error_threshold" gorm:"default:1"`
RequestedByUserID uint `json:"requested_by_user_id" gorm:"index"`
RequestedBy string `json:"requested_by" gorm:"size:120;index"`
Summary string `json:"summary" gorm:"type:text"`
ErrorMessage string `json:"error_message" gorm:"type:text"`
FindingTotal int `json:"finding_total" gorm:"default:0"`
CriticalCount int `json:"critical_count" gorm:"default:0"`
WarningCount int `json:"warning_count" gorm:"default:0"`
InfoCount int `json:"info_count" gorm:"default:0"`
AutoTriggerReason string `json:"auto_trigger_reason" gorm:"size:200"`
StartedAt *time.Time `json:"started_at" gorm:"index"`
FinishedAt *time.Time `json:"finished_at" gorm:"index"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
ClusterInspectionReport stores one persisted inspection execution. ClusterInspectionReport 存储一条持久化的集群巡检执行记录。
func (ClusterInspectionReport) TableName ¶
func (ClusterInspectionReport) TableName() string
TableName specifies the table name for ClusterInspectionReport. TableName 指定 ClusterInspectionReport 的表名。
func (*ClusterInspectionReport) ToInfo ¶
func (r *ClusterInspectionReport) ToInfo() *ClusterInspectionReportInfo
ToInfo converts a persisted inspection report into API view model. ToInfo 将巡检报告转换为 API 视图模型。
type ClusterInspectionReportDetailData ¶
type ClusterInspectionReportDetailData struct {
Report *ClusterInspectionReportInfo `json:"report"`
Findings []*ClusterInspectionFindingInfo `json:"findings"`
RelatedDiagnosticTask *DiagnosticTask `json:"related_diagnostic_task,omitempty"`
}
ClusterInspectionReportDetailData is the inspection report detail payload. ClusterInspectionReportDetailData 是巡检报告详情载荷。
type ClusterInspectionReportFilter ¶
type ClusterInspectionReportFilter struct {
ClusterID uint `json:"cluster_id"`
Status InspectionReportStatus `json:"status"`
TriggerSource InspectionTriggerSource `json:"trigger_source"`
Severity InspectionFindingSeverity `json:"severity"`
StartTime *time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ClusterInspectionReportFilter defines list filters for inspection reports. ClusterInspectionReportFilter 定义巡检报告列表过滤条件。
type ClusterInspectionReportInfo ¶
type ClusterInspectionReportInfo struct {
ID uint `json:"id"`
ClusterID uint `json:"cluster_id"`
ClusterName string `json:"cluster_name,omitempty"`
Status InspectionReportStatus `json:"status"`
TriggerSource InspectionTriggerSource `json:"trigger_source"`
LookbackMinutes int `json:"lookback_minutes"`
ErrorThreshold int `json:"error_threshold"`
RequestedByUserID uint `json:"requested_by_user_id"`
RequestedBy string `json:"requested_by"`
Summary string `json:"summary"`
ErrorMessage string `json:"error_message"`
FindingTotal int `json:"finding_total"`
CriticalCount int `json:"critical_count"`
WarningCount int `json:"warning_count"`
InfoCount int `json:"info_count"`
AutoTriggerReason string `json:"auto_trigger_reason,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ClusterInspectionReportInfo is the API view model for one inspection report. ClusterInspectionReportInfo 是巡检报告的 API 视图模型。
type ClusterInspectionReportsData ¶
type ClusterInspectionReportsData struct {
Items []*ClusterInspectionReportInfo `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
ClusterInspectionReportsData is the paginated inspection report payload. ClusterInspectionReportsData 是分页巡检报告载荷。
type ClusterOption ¶
type ClusterOption struct {
ClusterID uint `json:"cluster_id"`
ClusterName string `json:"cluster_name"`
}
ClusterOption is a selectable managed cluster for diagnostics workspace. ClusterOption 表示诊断中心筛选中可选的受管集群。
type CreateDiagnosticTaskRequest ¶
type CreateDiagnosticTaskRequest struct {
ClusterID uint `json:"cluster_id"`
TriggerSource DiagnosticTaskSourceType `json:"trigger_source"`
SourceRef DiagnosticTaskSourceRef `json:"source_ref"`
NodeScope DiagnosticTaskNodeScope `json:"node_scope,omitempty"`
SelectedNodeIDs []uint `json:"selected_node_ids"`
Options DiagnosticTaskOptions `json:"options"`
// LookbackMinutes overrides the default diagnostics collection window in minutes.
// LookbackMinutes 覆盖默认诊断采集时间窗口(分钟),0 表示使用默认或来源巡检窗口。
LookbackMinutes int `json:"lookback_minutes,omitempty"`
Summary string `json:"summary"`
AutoStart bool `json:"auto_start"`
}
CreateDiagnosticTaskRequest describes one task creation request. CreateDiagnosticTaskRequest 描述一条诊断任务创建请求。
type CreateInspectionAutoPolicyRequest ¶
type CreateInspectionAutoPolicyRequest struct {
ClusterID uint `json:"cluster_id"`
Name string `json:"name" binding:"required"`
Enabled bool `json:"enabled"`
Conditions InspectionConditionItems `json:"conditions" binding:"required"`
CooldownMinutes int `json:"cooldown_minutes"`
AutoCreateTask bool `json:"auto_create_task"`
AutoStartTask bool `json:"auto_start_task"`
TaskOptions *DiagnosticTaskOptions `json:"task_options,omitempty"`
}
CreateInspectionAutoPolicyRequest describes a create auto-policy request. CreateInspectionAutoPolicyRequest 描述创建自动策略的请求。
type DiagnosticExecutionRequest ¶
type DiagnosticExecutionRequest struct {
RequestID string
IdempotencyKey string
RequestHash string
Confirmed bool
ConfirmationID string
IsAdmin bool
ClientType string
}
DiagnosticExecutionRequest 保存诊断写操作的非敏感请求元数据。 DiagnosticExecutionRequest stores non-sensitive request metadata for a diagnostic write operation.
type DiagnosticHostDisplayContext ¶
DiagnosticHostDisplayContext stores host display labels for diagnostics API views. DiagnosticHostDisplayContext 存储 diagnostics API 视图的主机展示信息。
type DiagnosticLanguage ¶
type DiagnosticLanguage string
const ( DiagnosticLanguageZH DiagnosticLanguage = "zh" DiagnosticLanguageEN DiagnosticLanguage = "en" )
type DiagnosticLogEventType ¶
type DiagnosticLogEventType string
DiagnosticLogEventType represents the event type of task execution logs. DiagnosticLogEventType 表示诊断任务执行日志事件类型。
const ( DiagnosticLogEventTypeStarted DiagnosticLogEventType = "started" DiagnosticLogEventTypeProgress DiagnosticLogEventType = "progress" DiagnosticLogEventTypeSuccess DiagnosticLogEventType = "success" DiagnosticLogEventTypeFailed DiagnosticLogEventType = "failed" DiagnosticLogEventTypeNote DiagnosticLogEventType = "note" )
type DiagnosticLogLevel ¶
type DiagnosticLogLevel string
DiagnosticLogLevel represents the log level of task execution logs. DiagnosticLogLevel 表示诊断任务执行日志级别。
const ( DiagnosticLogLevelInfo DiagnosticLogLevel = "INFO" DiagnosticLogLevelWarn DiagnosticLogLevel = "WARN" DiagnosticLogLevelError DiagnosticLogLevel = "ERROR" )
type DiagnosticLogMetadata ¶
type DiagnosticLogMetadata map[string]interface{}
DiagnosticLogMetadata stores structured metadata for one task log. DiagnosticLogMetadata 存储单条任务日志的结构化元数据。
func (*DiagnosticLogMetadata) Scan ¶
func (m *DiagnosticLogMetadata) Scan(value interface{}) error
Scan implements sql.Scanner for JSON retrieval. Scan 实现 sql.Scanner,用于 JSON 读取。
type DiagnosticNodeExecution ¶
type DiagnosticNodeExecution struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
TaskID uint `json:"task_id" gorm:"index;not null;uniqueIndex:idx_diagnostics_task_node_scope"`
TaskStepID *uint `json:"task_step_id" gorm:"index"`
ClusterNodeID uint `json:"cluster_node_id" gorm:"index"`
NodeID uint `json:"node_id" gorm:"index"`
HostID uint `json:"host_id" gorm:"index;not null;uniqueIndex:idx_diagnostics_task_node_scope"`
HostName string `json:"host_name" gorm:"size:100"`
HostIP string `json:"host_ip" gorm:"size:64"`
Role string `json:"role" gorm:"size:32;not null;uniqueIndex:idx_diagnostics_task_node_scope"`
AgentID string `json:"agent_id" gorm:"size:120;index"`
InstallDir string `json:"install_dir" gorm:"size:255"`
Status DiagnosticTaskStatus `json:"status" gorm:"size:32;index;not null"`
CurrentStep DiagnosticStepCode `json:"current_step" gorm:"size:64;index"`
Message string `json:"message" gorm:"type:text"`
Error string `json:"error" gorm:"type:text"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
DiagnosticNodeExecution persists one node-level execution state. DiagnosticNodeExecution 存储单个节点级执行状态。
func (DiagnosticNodeExecution) TableName ¶
func (DiagnosticNodeExecution) TableName() string
TableName specifies the diagnostic node execution table name. TableName 指定诊断节点执行表名。
type DiagnosticPlanStep ¶
type DiagnosticPlanStep struct {
Sequence int `json:"sequence"`
Code DiagnosticStepCode `json:"code"`
Title string `json:"title"`
Description string `json:"description"`
NodeScoped bool `json:"node_scoped"`
Required bool `json:"required"`
}
DiagnosticPlanStep describes one ordered step in the diagnostic bundle task. DiagnosticPlanStep 描述诊断包任务中的有序步骤。
func DefaultDiagnosticTaskSteps ¶
func DefaultDiagnosticTaskSteps() []DiagnosticPlanStep
DefaultDiagnosticTaskSteps returns the MVP step order for bundle collection. DefaultDiagnosticTaskSteps 返回诊断包采集 MVP 的固定步骤顺序。
type DiagnosticStepCode ¶
type DiagnosticStepCode string
DiagnosticStepCode identifies one fixed step in the diagnostic bundle workflow. DiagnosticStepCode 表示诊断包编排中的固定步骤编码。
const ( DiagnosticStepCodeCollectErrorContext DiagnosticStepCode = "COLLECT_ERROR_CONTEXT" DiagnosticStepCodeCollectProcessEvents DiagnosticStepCode = "COLLECT_PROCESS_EVENTS" DiagnosticStepCodeCollectAlertSnapshot DiagnosticStepCode = "COLLECT_ALERT_SNAPSHOT" DiagnosticStepCodeCollectConfigSnapshot DiagnosticStepCode = "COLLECT_CONFIG_SNAPSHOT" DiagnosticStepCodeCollectLogSample DiagnosticStepCode = "COLLECT_LOG_SAMPLE" DiagnosticStepCodeCollectThreadDump DiagnosticStepCode = "COLLECT_THREAD_DUMP" DiagnosticStepCodeCollectJVMDump DiagnosticStepCode = "COLLECT_JVM_DUMP" DiagnosticStepCodeAssembleManifest DiagnosticStepCode = "ASSEMBLE_MANIFEST" DiagnosticStepCodeRenderHTMLSummary DiagnosticStepCode = "RENDER_HTML_SUMMARY" DiagnosticStepCodeComplete DiagnosticStepCode = "COMPLETE" )
type DiagnosticStepLog ¶
type DiagnosticStepLog struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
TaskID uint `json:"task_id" gorm:"index;not null"`
TaskStepID *uint `json:"task_step_id" gorm:"index"`
NodeExecutionID *uint `json:"node_execution_id" gorm:"index"`
StepCode DiagnosticStepCode `json:"step_code" gorm:"size:64;index"`
Level DiagnosticLogLevel `json:"level" gorm:"size:10;index;not null"`
EventType DiagnosticLogEventType `json:"event_type" gorm:"size:20;index;not null"`
Message string `json:"message" gorm:"type:text"`
CommandSummary string `json:"command_summary" gorm:"type:text"`
Metadata DiagnosticLogMetadata `json:"metadata" gorm:"type:json"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
}
DiagnosticStepLog persists one task execution log. DiagnosticStepLog 存储一条任务执行日志。
func (DiagnosticStepLog) TableName ¶
func (DiagnosticStepLog) TableName() string
TableName specifies the diagnostic step log table name. TableName 指定诊断步骤日志表名。
type DiagnosticTask ¶
type DiagnosticTask struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ExecutionID string `json:"execution_id,omitempty" gorm:"size:36;index"`
ClusterID uint `json:"cluster_id" gorm:"index;not null"`
TriggerSource DiagnosticTaskSourceType `json:"trigger_source" gorm:"size:40;index;not null"`
SourceRef DiagnosticTaskSourceRef `json:"source_ref" gorm:"type:json;not null"`
Options DiagnosticTaskOptions `json:"options" gorm:"type:json;not null"`
// LookbackMinutes controls the diagnostics collection window in minutes.
// LookbackMinutes 控制诊断采集时间窗口(分钟),0 表示使用默认或来源巡检窗口。
LookbackMinutes int `json:"lookback_minutes" gorm:"default:0"`
Status DiagnosticTaskStatus `json:"status" gorm:"size:32;index;not null"`
CurrentStep DiagnosticStepCode `json:"current_step" gorm:"size:64;index"`
FailureStep DiagnosticStepCode `json:"failure_step" gorm:"size:64"`
FailureReason string `json:"failure_reason" gorm:"type:text"`
SelectedNodes DiagnosticTaskNodeTargets `json:"selected_nodes" gorm:"type:json;not null"`
Summary string `json:"summary" gorm:"type:text"`
BundleDir string `json:"bundle_dir" gorm:"size:500"`
ManifestPath string `json:"manifest_path" gorm:"size:500"`
IndexPath string `json:"index_path" gorm:"size:500"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedBy uint `json:"created_by"`
CreatedByName string `json:"created_by_name" gorm:"size:120;index"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
Steps []DiagnosticTaskStep `json:"steps" gorm:"foreignKey:TaskID"`
NodeExecutions []DiagnosticNodeExecution `json:"node_executions" gorm:"foreignKey:TaskID"`
}
DiagnosticTask persists one diagnostic bundle task. DiagnosticTask 存储一条诊断包任务。
func (DiagnosticTask) TableName ¶
func (DiagnosticTask) TableName() string
TableName specifies the diagnostic task table name. TableName 指定诊断任务表名。
type DiagnosticTaskEvent ¶
type DiagnosticTaskEvent struct {
TaskID uint `json:"task_id"`
EventType DiagnosticTaskEventType `json:"event_type"`
Timestamp time.Time `json:"timestamp"`
TaskStatus DiagnosticTaskStatus `json:"task_status,omitempty"`
StepStatus DiagnosticTaskStatus `json:"step_status,omitempty"`
NodeStatus DiagnosticTaskStatus `json:"node_status,omitempty"`
CurrentStep DiagnosticStepCode `json:"current_step,omitempty"`
StepID *uint `json:"step_id,omitempty"`
StepCode DiagnosticStepCode `json:"step_code,omitempty"`
NodeExecutionID *uint `json:"node_execution_id,omitempty"`
HostID uint `json:"host_id,omitempty"`
HostName string `json:"host_name,omitempty"`
Level DiagnosticLogLevel `json:"level,omitempty"`
LogEventType DiagnosticLogEventType `json:"log_event_type,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
CommandSummary string `json:"command_summary,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
}
DiagnosticTaskEvent describes an incremental diagnostics task event for the frontend. DiagnosticTaskEvent 描述流向前端的诊断任务增量事件。
type DiagnosticTaskEventType ¶
type DiagnosticTaskEventType string
DiagnosticTaskEventType represents the event type in diagnostics task streaming. DiagnosticTaskEventType 表示诊断任务流中的事件类型。
const ( DiagnosticTaskEventTypeSnapshot DiagnosticTaskEventType = "snapshot" DiagnosticTaskEventTypeTaskUpdated DiagnosticTaskEventType = "task_updated" DiagnosticTaskEventTypeStepUpdated DiagnosticTaskEventType = "step_updated" DiagnosticTaskEventTypeNodeUpdated DiagnosticTaskEventType = "node_updated" DiagnosticTaskEventTypeLogAppended DiagnosticTaskEventType = "log_appended" )
type DiagnosticTaskListData ¶
type DiagnosticTaskListData struct {
Items []*DiagnosticTaskSummary `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
DiagnosticTaskListData is the paginated diagnostics task payload. DiagnosticTaskListData 是分页诊断任务列表载荷。
type DiagnosticTaskListFilter ¶
type DiagnosticTaskListFilter struct {
ClusterID uint `json:"cluster_id"`
TriggerSource DiagnosticTaskSourceType `json:"trigger_source"`
Status DiagnosticTaskStatus `json:"status"`
Page int `json:"page"`
PageSize int `json:"page_size"`
OwnerUserID uint `json:"-"`
IncludeAll bool `json:"-"`
}
DiagnosticTaskListFilter defines task list filters. DiagnosticTaskListFilter 定义任务列表过滤条件。
type DiagnosticTaskLogFilter ¶
type DiagnosticTaskLogFilter struct {
TaskID uint
StepCode DiagnosticStepCode
NodeExecutionID *uint
Level DiagnosticLogLevel
Page int
PageSize int
OwnerUserID uint
IncludeAll bool
}
DiagnosticTaskLogFilter defines log query filters. DiagnosticTaskLogFilter 定义任务日志查询过滤条件。
type DiagnosticTaskLogListData ¶
type DiagnosticTaskLogListData struct {
Items []*DiagnosticStepLog `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
DiagnosticTaskLogListData is the paginated diagnostics task log payload. DiagnosticTaskLogListData 是分页诊断任务日志载荷。
type DiagnosticTaskNodeScope ¶
type DiagnosticTaskNodeScope string
DiagnosticTaskNodeScope represents how task node targets are selected. DiagnosticTaskNodeScope 表示诊断任务节点选择范围。
const ( // DiagnosticTaskNodeScopeAll selects all managed nodes in the cluster. // DiagnosticTaskNodeScopeAll 表示选中集群内所有受管节点。 DiagnosticTaskNodeScopeAll DiagnosticTaskNodeScope = "all" // DiagnosticTaskNodeScopeRelated selects only nodes related to the source context (e.g. error group / finding). // DiagnosticTaskNodeScopeRelated 表示仅选中与来源上下文相关的节点(如错误组 / 巡检发现)。 DiagnosticTaskNodeScopeRelated DiagnosticTaskNodeScope = "related" // DiagnosticTaskNodeScopeCustom selects an explicit custom node list. // DiagnosticTaskNodeScopeCustom 表示使用显式自定义节点列表。 DiagnosticTaskNodeScopeCustom DiagnosticTaskNodeScope = "custom" )
type DiagnosticTaskNodeTarget ¶
type DiagnosticTaskNodeTarget struct {
ClusterNodeID uint `json:"cluster_node_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
HostName string `json:"host_name"`
HostIP string `json:"host_ip"`
Role string `json:"role"`
AgentID string `json:"agent_id"`
InstallDir string `json:"install_dir"`
}
DiagnosticTaskNodeTarget stores one selected node snapshot inside a task. DiagnosticTaskNodeTarget 存储任务中选择的单个节点快照。
type DiagnosticTaskNodeTargets ¶
type DiagnosticTaskNodeTargets []DiagnosticTaskNodeTarget
DiagnosticTaskNodeTargets stores selected node snapshots for one task. DiagnosticTaskNodeTargets 存储任务中选中的节点快照列表。
func (*DiagnosticTaskNodeTargets) Scan ¶
func (n *DiagnosticTaskNodeTargets) Scan(value interface{}) error
Scan implements sql.Scanner for JSON retrieval. Scan 实现 sql.Scanner,用于 JSON 读取。
type DiagnosticTaskOptions ¶
type DiagnosticTaskOptions struct {
IncludeThreadDump bool `json:"include_thread_dump"`
IncludeJVMDump bool `json:"include_jvm_dump"`
JVMDumpMinFreeMB int `json:"jvm_dump_min_free_mb,omitempty"`
}
DiagnosticTaskOptions stores bundle collection options. DiagnosticTaskOptions 存储诊断包采集选项。
func (DiagnosticTaskOptions) Normalize ¶
func (o DiagnosticTaskOptions) Normalize() DiagnosticTaskOptions
Normalize fills default option values. Normalize 填充采集选项默认值。
func (*DiagnosticTaskOptions) Scan ¶
func (o *DiagnosticTaskOptions) Scan(value interface{}) error
Scan implements sql.Scanner for JSON retrieval. Scan 实现 sql.Scanner,用于 JSON 读取。
type DiagnosticTaskSourceRef ¶
type DiagnosticTaskSourceRef struct {
ErrorGroupID uint `json:"error_group_id,omitempty"`
InspectionReportID uint `json:"inspection_report_id,omitempty"`
InspectionFindingID uint `json:"inspection_finding_id,omitempty"`
AlertID string `json:"alert_id,omitempty"`
}
DiagnosticTaskSourceRef stores typed references back to the originating context. DiagnosticTaskSourceRef 存储回溯到来源上下文的结构化引用。
func (*DiagnosticTaskSourceRef) Scan ¶
func (r *DiagnosticTaskSourceRef) Scan(value interface{}) error
Scan implements sql.Scanner for JSON retrieval. Scan 实现 sql.Scanner,用于 JSON 读取。
type DiagnosticTaskSourceType ¶
type DiagnosticTaskSourceType string
DiagnosticTaskSourceType represents where a diagnostic bundle task was created from. DiagnosticTaskSourceType 表示诊断任务的触发来源。
const ( DiagnosticTaskSourceManual DiagnosticTaskSourceType = "manual" DiagnosticTaskSourceErrorGroup DiagnosticTaskSourceType = "error_group" DiagnosticTaskSourceInspectionFinding DiagnosticTaskSourceType = "inspection_finding" DiagnosticTaskSourceAlert DiagnosticTaskSourceType = "alert" )
type DiagnosticTaskStatus ¶
type DiagnosticTaskStatus string
DiagnosticTaskStatus represents the common status for diagnostics tasks, steps, and node executions. DiagnosticTaskStatus 表示诊断任务、步骤和节点执行共用状态。
const ( DiagnosticTaskStatusPending DiagnosticTaskStatus = "pending" DiagnosticTaskStatusReady DiagnosticTaskStatus = "ready" DiagnosticTaskStatusRunning DiagnosticTaskStatus = "running" DiagnosticTaskStatusCancelRequested DiagnosticTaskStatus = "cancel_requested" DiagnosticTaskStatusCancelling DiagnosticTaskStatus = "cancelling" DiagnosticTaskStatusSucceeded DiagnosticTaskStatus = "succeeded" DiagnosticTaskStatusFailed DiagnosticTaskStatus = "failed" DiagnosticTaskStatusSkipped DiagnosticTaskStatus = "skipped" DiagnosticTaskStatusCancelled DiagnosticTaskStatus = "cancelled" )
type DiagnosticTaskStep ¶
type DiagnosticTaskStep struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
TaskID uint `json:"task_id" gorm:"index;not null;uniqueIndex:idx_diagnostics_task_step_code"`
Code DiagnosticStepCode `json:"code" gorm:"size:64;not null;uniqueIndex:idx_diagnostics_task_step_code"`
Sequence int `json:"sequence" gorm:"not null;index"`
Title string `json:"title" gorm:"size:120"`
Description string `json:"description" gorm:"type:text"`
Status DiagnosticTaskStatus `json:"status" gorm:"size:32;index;not null"`
Message string `json:"message" gorm:"type:text"`
Error string `json:"error" gorm:"type:text"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
DiagnosticTaskStep persists one task step. DiagnosticTaskStep 存储一条任务步骤。
func (DiagnosticTaskStep) TableName ¶
func (DiagnosticTaskStep) TableName() string
TableName specifies the diagnostic task step table name. TableName 指定诊断任务步骤表名。
type DiagnosticTaskSummary ¶
type DiagnosticTaskSummary struct {
ID uint `json:"id"`
ExecutionID string `json:"execution_id,omitempty"`
ClusterID uint `json:"cluster_id"`
TriggerSource DiagnosticTaskSourceType `json:"trigger_source"`
Status DiagnosticTaskStatus `json:"status"`
CurrentStep DiagnosticStepCode `json:"current_step"`
FailureStep DiagnosticStepCode `json:"failure_step"`
FailureReason string `json:"failure_reason"`
Summary string `json:"summary"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedBy uint `json:"created_by"`
CreatedByName string `json:"created_by_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
DiagnosticTaskSummary defines task list summary fields. DiagnosticTaskSummary 定义任务列表摘要字段。
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles diagnostics workspace HTTP requests. Handler 处理诊断中心工作台 HTTP 请求。
func NewHandler ¶
NewHandler creates a diagnostics handler. NewHandler 创建诊断中心处理器。
func (*Handler) CreateAutoPolicy ¶
CreateAutoPolicy handles POST /api/v1/diagnostics/auto-policies. CreateAutoPolicy 处理 POST /api/v1/diagnostics/auto-policies。
func (*Handler) CreateDiagnosticTask ¶
CreateDiagnosticTask handles POST /api/v1/diagnostics/tasks. CreateDiagnosticTask 处理 POST /api/v1/diagnostics/tasks。
func (*Handler) DeleteAutoPolicy ¶
DeleteAutoPolicy handles DELETE /api/v1/diagnostics/auto-policies/:id. DeleteAutoPolicy 处理 DELETE /api/v1/diagnostics/auto-policies/:id。
func (*Handler) DownloadDiagnosticTaskBundle ¶
DownloadDiagnosticTaskBundle handles GET /api/v1/diagnostics/tasks/:id/bundle. DownloadDiagnosticTaskBundle 处理 GET /api/v1/diagnostics/tasks/:id/bundle。
func (*Handler) GetAutoPolicy ¶
GetAutoPolicy handles GET /api/v1/diagnostics/auto-policies/:id. GetAutoPolicy 处理 GET /api/v1/diagnostics/auto-policies/:id。
func (*Handler) GetDiagnosticTask ¶
GetDiagnosticTaskDetail handles GET /api/v1/diagnostics/tasks/:id. GetDiagnosticTaskDetail 处理 GET /api/v1/diagnostics/tasks/:id。
func (*Handler) GetInspectionReportDetail ¶
GetInspectionReportDetail handles GET /api/v1/diagnostics/inspections/:id. GetInspectionReportDetail 处理 GET /api/v1/diagnostics/inspections/:id。
func (*Handler) GetSeatunnelErrorGroupDetail ¶
GetSeatunnelErrorGroupDetail handles GET /api/v1/diagnostics/errors/groups/:id. GetSeatunnelErrorGroupDetail 处理 GET /api/v1/diagnostics/errors/groups/:id。
func (*Handler) GetWorkspaceBootstrap ¶
GetWorkspaceBootstrap handles GET /api/v1/diagnostics/bootstrap GetWorkspaceBootstrap 处理 GET /api/v1/diagnostics/bootstrap
func (*Handler) ListAutoPolicies ¶
ListAutoPolicies handles GET /api/v1/diagnostics/auto-policies. ListAutoPolicies 处理 GET /api/v1/diagnostics/auto-policies。
func (*Handler) ListBuiltinConditionTemplates ¶
ListBuiltinConditionTemplates handles GET /api/v1/diagnostics/auto-policies/templates. ListBuiltinConditionTemplates 处理 GET /api/v1/diagnostics/auto-policies/templates。
func (*Handler) ListDiagnosticTaskLogs ¶
ListDiagnosticTaskLogs handles GET /api/v1/diagnostics/tasks/:id/logs. ListDiagnosticTaskLogs 处理 GET /api/v1/diagnostics/tasks/:id/logs。
func (*Handler) ListDiagnosticTaskSteps ¶
ListDiagnosticTaskSteps handles GET /api/v1/diagnostics/tasks/:id/steps. ListDiagnosticTaskSteps 处理 GET /api/v1/diagnostics/tasks/:id/steps。
func (*Handler) ListDiagnosticTasks ¶
ListDiagnosticTasks handles GET /api/v1/diagnostics/tasks. ListDiagnosticTasks 处理 GET /api/v1/diagnostics/tasks。
func (*Handler) ListInspectionReports ¶
ListInspectionReports handles GET /api/v1/diagnostics/inspections. ListInspectionReports 处理 GET /api/v1/diagnostics/inspections。
func (*Handler) ListSeatunnelErrorEvents ¶
ListSeatunnelErrorEvents handles GET /api/v1/diagnostics/errors/events. ListSeatunnelErrorEvents 处理 GET /api/v1/diagnostics/errors/events。
func (*Handler) ListSeatunnelErrorGroups ¶
ListSeatunnelErrorGroups handles GET /api/v1/diagnostics/errors/groups. ListSeatunnelErrorGroups 处理 GET /api/v1/diagnostics/errors/groups。
func (*Handler) PreviewDiagnosticTaskFile ¶
PreviewDiagnosticTaskFile handles GET /api/v1/diagnostics/tasks/:id/files/*path. PreviewDiagnosticTaskFile 处理 GET /api/v1/diagnostics/tasks/:id/files/*path。
func (*Handler) PreviewDiagnosticTaskHTML ¶
PreviewDiagnosticTaskHTML handles GET /api/v1/diagnostics/tasks/:id/html. PreviewDiagnosticTaskHTML 处理 GET /api/v1/diagnostics/tasks/:id/html。
func (*Handler) SetAuditRepository ¶
func (h *Handler) SetAuditRepository(repo *audit.Repository)
SetAuditRepository 设置诊断资源访问使用的审计仓库。 SetAuditRepository sets the audit repository used for diagnostic resource access.
func (*Handler) StartDiagnosticTask ¶
StartDiagnosticTask handles POST /api/v1/diagnostics/tasks/:id/start. StartDiagnosticTask 处理 POST /api/v1/diagnostics/tasks/:id/start。
func (*Handler) StartInspection ¶
StartInspection handles POST /api/v1/diagnostics/inspections. StartInspection 处理 POST /api/v1/diagnostics/inspections。
func (*Handler) StreamDiagnosticTaskEvents ¶
StreamDiagnosticTaskEvents handles GET /api/v1/diagnostics/tasks/:id/events/stream. StreamDiagnosticTaskEvents 处理 GET /api/v1/diagnostics/tasks/:id/events/stream。
func (*Handler) UpdateAutoPolicy ¶
UpdateAutoPolicy handles PUT /api/v1/diagnostics/auto-policies/:id. UpdateAutoPolicy 处理 PUT /api/v1/diagnostics/auto-policies/:id。
type IngestSeatunnelErrorRequest ¶
type IngestSeatunnelErrorRequest struct {
ClusterID uint `json:"cluster_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
AgentID string `json:"agent_id"`
Role string `json:"role"`
InstallDir string `json:"install_dir"`
SourceFile string `json:"source_file"`
SourceKind string `json:"source_kind"`
JobID string `json:"job_id"`
OccurredAt time.Time `json:"occurred_at"`
Message string `json:"message"`
Evidence string `json:"evidence"`
CursorStart int64 `json:"cursor_start"`
CursorEnd int64 `json:"cursor_end"`
}
IngestSeatunnelErrorRequest represents one structured Seatunnel error ingestion request. IngestSeatunnelErrorRequest 表示一条结构化 Seatunnel 错误入库请求。
type InspectionAutoPolicy ¶
type InspectionAutoPolicy struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ClusterID uint `json:"cluster_id" gorm:"index;not null;default:0"`
Name string `json:"name" gorm:"size:200;not null"`
Enabled bool `json:"enabled" gorm:"not null;default:true"`
Conditions InspectionConditionItems `json:"conditions" gorm:"type:json;not null"`
CooldownMinutes int `json:"cooldown_minutes" gorm:"not null;default:30"`
// AutoCreateTask controls whether a diagnostics bundle task should be created automatically after an inspection is triggered.
// AutoCreateTask 控制巡检触发后是否自动创建诊断包任务。
AutoCreateTask bool `json:"auto_create_task" gorm:"not null;default:false"`
// AutoStartTask controls whether the auto-created diagnostics task should start immediately.
// AutoStartTask 控制自动创建的诊断任务是否立即开始执行。
AutoStartTask bool `json:"auto_start_task" gorm:"not null;default:true"`
// TaskOptions configures the diagnostics task bundle options (thread dump / JVM dump / log sample, etc.).
// TaskOptions 配置诊断任务的采集选项(线程栈 / JVM Dump / 日志采样等)。
TaskOptions DiagnosticTaskOptions `json:"task_options" gorm:"type:json;not null"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
InspectionAutoPolicy persists one auto-inspection trigger policy. InspectionAutoPolicy 存储一条自动巡检触发策略。
func (InspectionAutoPolicy) TableName ¶
func (InspectionAutoPolicy) TableName() string
TableName specifies the auto-policy table name. TableName 指定自动策略表名。
func (*InspectionAutoPolicy) ToInfo ¶
func (p *InspectionAutoPolicy) ToInfo() *InspectionAutoPolicyInfo
ToInfo converts a persisted auto-policy into API view model. ToInfo 将自动策略转换为 API 视图模型。
type InspectionAutoPolicyInfo ¶
type InspectionAutoPolicyInfo struct {
ID uint `json:"id"`
ClusterID uint `json:"cluster_id"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Conditions InspectionConditionItems `json:"conditions"`
CooldownMinutes int `json:"cooldown_minutes"`
AutoCreateTask bool `json:"auto_create_task"`
AutoStartTask bool `json:"auto_start_task"`
TaskOptions DiagnosticTaskOptions `json:"task_options"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
InspectionAutoPolicyInfo is the API view model for one auto-policy. InspectionAutoPolicyInfo 是自动策略的 API 视图模型。
type InspectionAutoPolicyListData ¶
type InspectionAutoPolicyListData struct {
Items []*InspectionAutoPolicyInfo `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
InspectionAutoPolicyListData is the paginated auto-policy list payload. InspectionAutoPolicyListData 是分页自动策略列表载荷。
type InspectionConditionCategory ¶
type InspectionConditionCategory string
InspectionConditionCategory groups condition templates by domain. InspectionConditionCategory 按领域对条件模板分类。
const ( // ConditionCategoryJavaError groups Java fatal error conditions. // ConditionCategoryJavaError 分组 Java 致命错误条件。 ConditionCategoryJavaError InspectionConditionCategory = "java_error" // ConditionCategoryPrometheus groups Prometheus metric conditions. // ConditionCategoryPrometheus 分组 Prometheus 指标条件。 ConditionCategoryPrometheus InspectionConditionCategory = "prometheus" // ConditionCategoryErrorRate groups error rate conditions. // ConditionCategoryErrorRate 分组错误频率条件。 ConditionCategoryErrorRate InspectionConditionCategory = "error_rate" // ConditionCategoryNodeUnhealthy groups node health conditions. // ConditionCategoryNodeUnhealthy 分组节点健康条件。 ConditionCategoryNodeUnhealthy InspectionConditionCategory = "node_unhealthy" // ConditionCategoryAlertFiring groups alert rule conditions. // ConditionCategoryAlertFiring 分组告警规则条件。 ConditionCategoryAlertFiring InspectionConditionCategory = "alert_firing" // ConditionCategorySchedule groups schedule-based conditions. // ConditionCategorySchedule 分组定时巡检条件。 ConditionCategorySchedule InspectionConditionCategory = "schedule" )
type InspectionConditionItem ¶
type InspectionConditionItem struct {
TemplateCode InspectionConditionTemplateCode `json:"template_code"`
Enabled bool `json:"enabled"`
ThresholdOverride *int `json:"threshold_override,omitempty"`
WindowMinutesOverride *int `json:"window_minutes_override,omitempty"`
CronExprOverride string `json:"cron_expr_override,omitempty"`
ExtraKeywords []string `json:"extra_keywords,omitempty"`
}
InspectionConditionItem stores one user-configured condition within an auto-policy. InspectionConditionItem 存储自动策略中的一条用户配置的条件项。
type InspectionConditionItems ¶
type InspectionConditionItems []InspectionConditionItem
InspectionConditionItems is a slice of InspectionConditionItem for JSON column storage. InspectionConditionItems 是 InspectionConditionItem 切片,用于 JSON 列存储。
func (*InspectionConditionItems) Scan ¶
func (items *InspectionConditionItems) Scan(value interface{}) error
Scan implements sql.Scanner for JSON retrieval. Scan 实现 sql.Scanner,用于 JSON 读取。
type InspectionConditionTemplate ¶
type InspectionConditionTemplate struct {
Code InspectionConditionTemplateCode `json:"code"`
Category InspectionConditionCategory `json:"category"`
Name string `json:"name"`
Description string `json:"description"`
DefaultThreshold int `json:"default_threshold"`
DefaultWindowMinutes int `json:"default_window_minutes"`
DefaultCronExpr string `json:"default_cron_expr,omitempty"`
ImmediateOnMatch bool `json:"immediate_on_match"`
}
InspectionConditionTemplate describes one built-in condition template. InspectionConditionTemplate 描述一个内置条件模板。
type InspectionConditionTemplateCode ¶
type InspectionConditionTemplateCode string
InspectionConditionTemplateCode identifies one built-in auto-inspection condition template. InspectionConditionTemplateCode 标识一个内置的自动巡检条件模板。
const ( // ConditionCodeJavaOOM triggers on java.lang.OutOfMemoryError. // ConditionCodeJavaOOM 在 java.lang.OutOfMemoryError 时触发。 ConditionCodeJavaOOM InspectionConditionTemplateCode = "JAVA_OOM" // ConditionCodeJavaStackOverflow triggers on java.lang.StackOverflowError. // ConditionCodeJavaStackOverflow 在 java.lang.StackOverflowError 时触发。 ConditionCodeJavaStackOverflow InspectionConditionTemplateCode = "JAVA_STACKOVERFLOW" // ConditionCodeJavaMetaspace triggers on Metaspace exhaustion. // ConditionCodeJavaMetaspace 在 Metaspace 耗尽时触发。 ConditionCodeJavaMetaspace InspectionConditionTemplateCode = "JAVA_METASPACE" // ConditionCodePromGCFrequent triggers on frequent GC pauses. // ConditionCodePromGCFrequent 在 GC 频繁时触发。 ConditionCodePromGCFrequent InspectionConditionTemplateCode = "PROM_GC_FREQUENT" // ConditionCodePromHeapRising triggers on monotonically rising heap usage. // ConditionCodePromHeapRising 在堆内存持续上涨时触发。 ConditionCodePromHeapRising InspectionConditionTemplateCode = "PROM_HEAP_RISING" // ConditionCodePromHeapHigh triggers on high heap utilization. // ConditionCodePromHeapHigh 在堆内存使用率高时触发。 ConditionCodePromHeapHigh InspectionConditionTemplateCode = "PROM_HEAP_HIGH" // ConditionCodePromCPUHigh triggers on sustained high CPU usage. // ConditionCodePromCPUHigh 在 CPU 持续高负载时触发。 ConditionCodePromCPUHigh InspectionConditionTemplateCode = "PROM_CPU_HIGH" // ConditionCodeErrorSpike triggers on error frequency spike. // ConditionCodeErrorSpike 在错误频率激增时触发。 ConditionCodeErrorSpike InspectionConditionTemplateCode = "ERROR_SPIKE" // ConditionCodeNodeUnhealthy triggers on sustained node unhealthy state. // ConditionCodeNodeUnhealthy 在节点持续异常时触发。 ConditionCodeNodeUnhealthy InspectionConditionTemplateCode = "NODE_UNHEALTHY" // ConditionCodeAlertFiring triggers on a specific alert rule firing. // ConditionCodeAlertFiring 在指定告警规则触发时触发。 ConditionCodeAlertFiring InspectionConditionTemplateCode = "ALERT_FIRING" // ConditionCodeScheduled triggers on a cron schedule. // ConditionCodeScheduled 按 Cron 表达式定时触发。 ConditionCodeScheduled InspectionConditionTemplateCode = "SCHEDULED" )
type InspectionEvaluationResult ¶
type InspectionEvaluationResult struct {
ClusterID uint `json:"cluster_id"`
GeneratedAt time.Time `json:"generated_at"`
Summary string `json:"summary"`
FindingTotal int `json:"finding_total"`
CriticalCount int `json:"critical_count"`
WarningCount int `json:"warning_count"`
InfoCount int `json:"info_count"`
Findings []*ClusterInspectionFinding `json:"findings"`
}
InspectionEvaluationResult contains the current inspection findings before persistence. InspectionEvaluationResult 表示巡检发现项在落库前的评估结果。
type InspectionFindingSeverity ¶
type InspectionFindingSeverity string
InspectionFindingSeverity represents finding severity in an inspection report. InspectionFindingSeverity 表示巡检发现项的严重级别。
const ( // InspectionFindingSeverityInfo indicates informational findings. // InspectionFindingSeverityInfo 表示信息级发现项。 InspectionFindingSeverityInfo InspectionFindingSeverity = "info" // InspectionFindingSeverityWarning indicates warning findings. // InspectionFindingSeverityWarning 表示告警级发现项。 InspectionFindingSeverityWarning InspectionFindingSeverity = "warning" // InspectionFindingSeverityCritical indicates critical findings. // InspectionFindingSeverityCritical 表示严重发现项。 InspectionFindingSeverityCritical InspectionFindingSeverity = "critical" )
type InspectionReportStatus ¶
type InspectionReportStatus string
InspectionReportStatus represents the execution status of one inspection report. InspectionReportStatus 表示一条巡检报告的执行状态。
const ( // InspectionReportStatusPending means the inspection has been created but not started. // InspectionReportStatusPending 表示巡检已创建但尚未开始。 InspectionReportStatusPending InspectionReportStatus = "pending" // InspectionReportStatusRunning means the inspection is currently evaluating signals. // InspectionReportStatusRunning 表示巡检正在执行信号评估。 InspectionReportStatusRunning InspectionReportStatus = "running" // InspectionReportStatusCompleted means the inspection finished successfully. // InspectionReportStatusCompleted 表示巡检已成功完成。 InspectionReportStatusCompleted InspectionReportStatus = "completed" // InspectionReportStatusFailed means the inspection execution failed. // InspectionReportStatusFailed 表示巡检执行失败。 InspectionReportStatusFailed InspectionReportStatus = "failed" )
type InspectionTriggerSource ¶
type InspectionTriggerSource string
InspectionTriggerSource represents where an inspection was initiated from. InspectionTriggerSource 表示巡检的触发来源。
const ( // InspectionTriggerSourceManual indicates a user manually created the inspection. // InspectionTriggerSourceManual 表示用户手动发起巡检。 InspectionTriggerSourceManual InspectionTriggerSource = "manual" // InspectionTriggerSourceClusterDetail indicates the inspection was started from cluster detail page. // InspectionTriggerSourceClusterDetail 表示巡检来自集群详情页。 InspectionTriggerSourceClusterDetail InspectionTriggerSource = "cluster_detail" // InspectionTriggerSourceDiagnosticsWorkspace indicates the inspection was started from diagnostics workspace. // InspectionTriggerSourceDiagnosticsWorkspace 表示巡检来自诊断中心工作台。 InspectionTriggerSourceDiagnosticsWorkspace InspectionTriggerSource = "diagnostics_workspace" // InspectionTriggerSourceAuto indicates the inspection was triggered automatically by an auto-policy. // InspectionTriggerSourceAuto 表示巡检由自动策略自动触发。 InspectionTriggerSourceAuto InspectionTriggerSource = "auto" )
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides persistence for diagnostics domain models. Repository 为诊断领域模型提供持久化能力。
func NewRepository ¶
func NewRepository(db *gorm.DB) *Repository
NewRepository creates a diagnostics repository. NewRepository 创建诊断仓储。
func (*Repository) CreateAutoPolicy ¶
func (r *Repository) CreateAutoPolicy(ctx context.Context, policy *InspectionAutoPolicy) error
CreateAutoPolicy persists one new auto-inspection policy. CreateAutoPolicy 持久化一条新的自动巡检策略。
func (*Repository) CreateDiagnosticNodeExecutions ¶
func (r *Repository) CreateDiagnosticNodeExecutions(ctx context.Context, nodes []*DiagnosticNodeExecution) error
CreateDiagnosticNodeExecutions creates diagnostics node execution records in batch. CreateDiagnosticNodeExecutions 批量创建诊断节点执行记录。
func (*Repository) CreateDiagnosticStepLog ¶
func (r *Repository) CreateDiagnosticStepLog(ctx context.Context, log *DiagnosticStepLog) error
CreateDiagnosticStepLog creates one diagnostics step log. CreateDiagnosticStepLog 创建一条诊断步骤日志。
func (*Repository) CreateDiagnosticTask ¶
func (r *Repository) CreateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
CreateDiagnosticTask persists one diagnostics task. CreateDiagnosticTask 持久化一条诊断任务。
func (*Repository) CreateDiagnosticTaskSteps ¶
func (r *Repository) CreateDiagnosticTaskSteps(ctx context.Context, steps []*DiagnosticTaskStep) error
CreateDiagnosticTaskSteps creates diagnostics task steps in batch. CreateDiagnosticTaskSteps 批量创建诊断任务步骤。
func (*Repository) CreateErrorEvent ¶
func (r *Repository) CreateErrorEvent(ctx context.Context, event *SeatunnelErrorEvent) error
CreateErrorEvent persists one new error event. CreateErrorEvent 持久化一个新的错误事件。
func (*Repository) CreateErrorGroup ¶
func (r *Repository) CreateErrorGroup(ctx context.Context, group *SeatunnelErrorGroup) error
CreateErrorGroup persists one new error group. CreateErrorGroup 持久化一个新的错误组。
func (*Repository) CreateInspectionFinding ¶
func (r *Repository) CreateInspectionFinding(ctx context.Context, finding *ClusterInspectionFinding) error
CreateInspectionFinding persists one new inspection finding. CreateInspectionFinding 持久化一条新的巡检发现项。
func (*Repository) CreateInspectionFindings ¶
func (r *Repository) CreateInspectionFindings(ctx context.Context, findings []*ClusterInspectionFinding) error
CreateInspectionFindings persists multiple inspection findings. CreateInspectionFindings 持久化多条巡检发现项。
func (*Repository) CreateInspectionReport ¶
func (r *Repository) CreateInspectionReport(ctx context.Context, report *ClusterInspectionReport) error
CreateInspectionReport persists one new inspection report. CreateInspectionReport 持久化一条新的巡检报告。
func (*Repository) DeleteAutoPolicy ¶
func (r *Repository) DeleteAutoPolicy(ctx context.Context, id uint) error
DeleteAutoPolicy deletes one auto-inspection policy by identifier. DeleteAutoPolicy 根据标识删除一条自动巡检策略。
func (*Repository) GetAutoPolicyByID ¶
func (r *Repository) GetAutoPolicyByID(ctx context.Context, id uint) (*InspectionAutoPolicy, error)
GetAutoPolicyByID retrieves one auto-inspection policy by identifier. GetAutoPolicyByID 根据标识获取一条自动巡检策略。
func (*Repository) GetDiagnosticTaskByID ¶
func (r *Repository) GetDiagnosticTaskByID(ctx context.Context, id uint) (*DiagnosticTask, error)
GetDiagnosticTaskByID fetches one diagnostics task with its related steps and node executions. GetDiagnosticTaskByID 获取一条诊断任务及其关联步骤和节点执行。
func (*Repository) GetDiagnosticTaskByIDForOwner ¶
func (r *Repository) GetDiagnosticTaskByIDForOwner(ctx context.Context, id, ownerUserID uint, includeAll bool) (*DiagnosticTask, error)
GetDiagnosticTaskByIDForOwner 按用户归属读取诊断任务,管理员可跳过归属限制。 GetDiagnosticTaskByIDForOwner loads a diagnostics task under owner scope, while administrators may bypass the owner filter.
func (*Repository) GetErrorGroupByFingerprint ¶
func (r *Repository) GetErrorGroupByFingerprint(ctx context.Context, fingerprint string) (*SeatunnelErrorGroup, error)
GetErrorGroupByFingerprint retrieves one error group by fingerprint. GetErrorGroupByFingerprint 根据指纹获取一个错误组。
func (*Repository) GetErrorGroupByID ¶
func (r *Repository) GetErrorGroupByID(ctx context.Context, id uint) (*SeatunnelErrorGroup, error)
GetErrorGroupByID retrieves one error group by identifier. GetErrorGroupByID 根据标识获取一个错误组。
func (*Repository) GetInspectionFindingByID ¶
func (r *Repository) GetInspectionFindingByID(ctx context.Context, id uint) (*ClusterInspectionFinding, error)
GetInspectionFindingByID retrieves one inspection finding by identifier. GetInspectionFindingByID 根据标识获取一条巡检发现项。
func (*Repository) GetInspectionReportByID ¶
func (r *Repository) GetInspectionReportByID(ctx context.Context, id uint) (*ClusterInspectionReport, error)
GetInspectionReportByID retrieves one inspection report by identifier. GetInspectionReportByID 根据标识获取一条巡检报告。
func (*Repository) GetLastInspectionReportForCluster ¶
func (r *Repository) GetLastInspectionReportForCluster(ctx context.Context, clusterID uint) (*ClusterInspectionReport, error)
GetLastInspectionReportForCluster returns the most recent inspection report for a cluster. GetLastInspectionReportForCluster 返回指定集群的最近一条巡检报告。
func (*Repository) GetLastInspectionReportForRequester ¶
func (r *Repository) GetLastInspectionReportForRequester(ctx context.Context, clusterID uint, requestedBy string) (*ClusterInspectionReport, error)
GetLastInspectionReportForRequester returns the most recent inspection report for one cluster/requester pair. GetLastInspectionReportForRequester 返回指定集群与请求者组合下最近的一条巡检报告。
func (*Repository) GetLatestDiagnosticTaskByInspectionReportID ¶
func (r *Repository) GetLatestDiagnosticTaskByInspectionReportID(ctx context.Context, reportID uint) (*DiagnosticTask, error)
GetLatestDiagnosticTaskByInspectionReportID returns the most recent diagnostic task whose source_ref.inspection_report_id equals reportID, with steps and node executions preloaded. Returns nil, nil when no such task exists.
func (*Repository) GetLogCursor ¶
func (r *Repository) GetLogCursor(ctx context.Context, agentID, installDir, role, sourceFile string) (*SeatunnelLogCursor, error)
GetLogCursor gets one cursor by agent + install_dir + role + source_file. GetLogCursor 根据 agent + install_dir + role + source_file 获取一个游标。
func (*Repository) ListAutoPolicies ¶
func (r *Repository) ListAutoPolicies(ctx context.Context, clusterID *uint, page, pageSize int) ([]*InspectionAutoPolicy, int64, error)
ListAutoPolicies returns paginated auto-inspection policies with optional cluster filter. clusterID nil = all, clusterID pointing to 0 = global only. ListAutoPolicies 返回分页自动巡检策略,支持可选集群过滤。 clusterID 为 nil 表示全部,指向 0 表示仅全局策略。
func (*Repository) ListDiagnosticNodeExecutions ¶
func (r *Repository) ListDiagnosticNodeExecutions(ctx context.Context, taskID uint) ([]*DiagnosticNodeExecution, error)
ListDiagnosticNodeExecutions lists node executions of one diagnostics task. ListDiagnosticNodeExecutions 获取单个诊断任务的节点执行列表。
func (*Repository) ListDiagnosticStepLogs ¶
func (r *Repository) ListDiagnosticStepLogs(ctx context.Context, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
ListDiagnosticStepLogs queries diagnostics task logs with filters and pagination. ListDiagnosticStepLogs 按过滤条件分页查询诊断任务日志。
func (*Repository) ListDiagnosticTaskSteps ¶
func (r *Repository) ListDiagnosticTaskSteps(ctx context.Context, taskID uint) ([]*DiagnosticTaskStep, error)
ListDiagnosticTaskSteps lists steps of one diagnostics task. ListDiagnosticTaskSteps 获取单个诊断任务的步骤列表。
func (*Repository) ListDiagnosticTaskStepsForOwner ¶
func (r *Repository) ListDiagnosticTaskStepsForOwner(ctx context.Context, taskID, ownerUserID uint, includeAll bool) ([]*DiagnosticTaskStep, error)
ListDiagnosticTaskStepsForOwner 仅在调用者可以查看父任务时返回步骤。 ListDiagnosticTaskStepsForOwner returns steps only when the parent task is visible to the actor.
func (*Repository) ListDiagnosticTasks ¶
func (r *Repository) ListDiagnosticTasks(ctx context.Context, filter *DiagnosticTaskListFilter) ([]*DiagnosticTaskSummary, int64, error)
ListDiagnosticTasks queries diagnostics task summaries with filters and pagination. ListDiagnosticTasks 按过滤条件分页查询诊断任务摘要。
func (*Repository) ListEnabledPoliciesForCluster ¶
func (r *Repository) ListEnabledPoliciesForCluster(ctx context.Context, clusterID uint) ([]*InspectionAutoPolicy, error)
ListEnabledPoliciesForCluster returns enabled policies applicable to a cluster. It returns policies where ClusterID equals the given clusterID OR ClusterID is 0 (global). ListEnabledPoliciesForCluster 返回适用于指定集群的已启用策略。 返回 ClusterID 等于给定值或 ClusterID 为 0(全局)的策略。
func (*Repository) ListErrorEvents ¶
func (r *Repository) ListErrorEvents(ctx context.Context, filter *SeatunnelErrorEventFilter) ([]*SeatunnelErrorEvent, int64, error)
ListErrorEvents lists error events with filters. ListErrorEvents 返回带过滤条件的错误事件列表。
func (*Repository) ListErrorGroups ¶
func (r *Repository) ListErrorGroups(ctx context.Context, filter *SeatunnelErrorGroupFilter) ([]*SeatunnelErrorGroup, int64, error)
ListErrorGroups lists aggregated error groups with optional event-scoped filters. ListErrorGroups 返回聚合后的错误组列表,支持事件维度过滤。
func (*Repository) ListEventsByGroupID ¶
func (r *Repository) ListEventsByGroupID(ctx context.Context, filter *SeatunnelErrorEventFilter, limit int) ([]*SeatunnelErrorEvent, error)
ListEventsByGroupID lists recent events for one error group. ListEventsByGroupID 返回一个错误组的近期事件。
func (*Repository) ListInspectionFindings ¶
func (r *Repository) ListInspectionFindings(ctx context.Context, filter *ClusterInspectionFindingFilter) ([]*ClusterInspectionFinding, int64, error)
ListInspectionFindings lists inspection findings with filters. ListInspectionFindings 返回带过滤条件的巡检发现项列表。
func (*Repository) ListInspectionFindingsByReportID ¶
func (r *Repository) ListInspectionFindingsByReportID(ctx context.Context, reportID uint) ([]*ClusterInspectionFinding, error)
ListInspectionFindingsByReportID lists inspection findings for one report. ListInspectionFindingsByReportID 返回一条巡检报告下的发现项列表。
func (*Repository) ListInspectionReports ¶
func (r *Repository) ListInspectionReports(ctx context.Context, filter *ClusterInspectionReportFilter) ([]*ClusterInspectionReport, int64, error)
ListInspectionReports lists inspection reports with filters. ListInspectionReports 返回带过滤条件的巡检报告列表。
func (*Repository) ListLogCursorsByAgent ¶
func (r *Repository) ListLogCursorsByAgent(ctx context.Context, agentID string) ([]*SeatunnelLogCursor, error)
ListLogCursorsByAgent lists all log cursors for a given agent. ListLogCursorsByAgent 返回某个 Agent 的所有日志游标。
func (*Repository) ListRecentErrorGroupBursts ¶
func (r *Repository) ListRecentErrorGroupBursts(ctx context.Context, clusterID uint, since time.Time, limit int) ([]*recentErrorGroupBurst, error)
ListRecentErrorGroupBursts aggregates recent error events by group within one cluster. ListRecentErrorGroupBursts 返回单个集群在给定时间窗口内按错误组聚合的近期错误突增结果。
func (*Repository) SkipPendingDiagnosticNodeExecutions ¶
func (r *Repository) SkipPendingDiagnosticNodeExecutions(ctx context.Context, taskID uint, message string, completedAt time.Time) error
SkipPendingDiagnosticNodeExecutions 将尚未开始的节点执行标记为跳过。 SkipPendingDiagnosticNodeExecutions marks node executions that have not started as skipped.
func (*Repository) Transaction ¶
func (r *Repository) Transaction(ctx context.Context, fn func(tx *Repository) error) error
Transaction executes diagnostics writes in a single transaction. Transaction 在单个事务中执行诊断写操作。
func (*Repository) UpdateAutoPolicy ¶
func (r *Repository) UpdateAutoPolicy(ctx context.Context, policy *InspectionAutoPolicy) error
UpdateAutoPolicy updates one existing auto-inspection policy. UpdateAutoPolicy 更新一条已有的自动巡检策略。
func (*Repository) UpdateDiagnosticNodeExecution ¶
func (r *Repository) UpdateDiagnosticNodeExecution(ctx context.Context, node *DiagnosticNodeExecution) error
UpdateDiagnosticNodeExecution updates one diagnostics node execution. UpdateDiagnosticNodeExecution 更新一条诊断节点执行记录。
func (*Repository) UpdateDiagnosticTask ¶
func (r *Repository) UpdateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
UpdateDiagnosticTask updates one diagnostics task. UpdateDiagnosticTask 更新一条诊断任务。
func (*Repository) UpdateDiagnosticTaskFields ¶
func (r *Repository) UpdateDiagnosticTaskFields(ctx context.Context, taskID uint, expected []DiagnosticTaskStatus, updates map[string]any) (bool, error)
UpdateDiagnosticTaskFields 按旧状态条件更新诊断任务字段,避免完成与取消互相覆盖。 UpdateDiagnosticTaskFields updates diagnostic task fields under an expected-status guard to prevent completion and cancellation races.
func (*Repository) UpdateDiagnosticTaskStep ¶
func (r *Repository) UpdateDiagnosticTaskStep(ctx context.Context, step *DiagnosticTaskStep) error
UpdateDiagnosticTaskStep updates one diagnostics task step. UpdateDiagnosticTaskStep 更新一条诊断任务步骤。
func (*Repository) UpdateErrorGroup ¶
func (r *Repository) UpdateErrorGroup(ctx context.Context, group *SeatunnelErrorGroup) error
UpdateErrorGroup updates one existing error group. UpdateErrorGroup 更新一个已有错误组。
func (*Repository) UpdateInspectionReport ¶
func (r *Repository) UpdateInspectionReport(ctx context.Context, report *ClusterInspectionReport) error
UpdateInspectionReport updates one existing inspection report. UpdateInspectionReport 更新一条已有巡检报告。
func (*Repository) UpdateInspectionReportAutoTriggerReason ¶
func (r *Repository) UpdateInspectionReportAutoTriggerReason(ctx context.Context, reportID uint, reason string) error
UpdateInspectionReportAutoTriggerReason updates one inspection report auto-trigger reason only. UpdateInspectionReportAutoTriggerReason 仅更新一条巡检报告的自动触发原因。
func (*Repository) UpsertLogCursor ¶
func (r *Repository) UpsertLogCursor(ctx context.Context, cursor *SeatunnelLogCursor) error
UpsertLogCursor creates or updates one source file cursor. UpsertLogCursor 创建或更新一个来源文件游标。
type Response ¶
type Response struct {
ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data"`
}
Response is the standard API response for diagnostics endpoints. Response 是诊断接口的标准响应结构。
type SeatunnelErrorEvent ¶
type SeatunnelErrorEvent struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
ErrorGroupID uint `json:"error_group_id" gorm:"index;not null"`
Fingerprint string `json:"fingerprint" gorm:"size:64;index;not null"`
ClusterID uint `json:"cluster_id" gorm:"index"`
NodeID uint `json:"node_id" gorm:"index"`
HostID uint `json:"host_id" gorm:"index"`
AgentID string `json:"agent_id" gorm:"size:100;index;not null"`
Role string `json:"role" gorm:"size:20;index"`
InstallDir string `json:"install_dir" gorm:"size:255"`
SourceFile string `json:"source_file" gorm:"size:500;index"`
SourceKind string `json:"source_kind" gorm:"size:20;index"`
JobID string `json:"job_id" gorm:"size:100;index"`
OccurredAt time.Time `json:"occurred_at" gorm:"index"`
Message string `json:"message" gorm:"type:text"`
ExceptionClass string `json:"exception_class" gorm:"size:255;index"`
NormalizedText string `json:"normalized_text" gorm:"type:text"`
Evidence string `json:"evidence" gorm:"type:text"`
CursorStart int64 `json:"cursor_start"`
CursorEnd int64 `json:"cursor_end"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
}
SeatunnelErrorEvent stores one structured Seatunnel ERROR occurrence. SeatunnelErrorEvent 存储一条结构化 Seatunnel ERROR 事件。
func (SeatunnelErrorEvent) TableName ¶
func (SeatunnelErrorEvent) TableName() string
TableName specifies the table name for SeatunnelErrorEvent. TableName 指定 SeatunnelErrorEvent 的表名。
func (*SeatunnelErrorEvent) ToInfo ¶
func (e *SeatunnelErrorEvent) ToInfo(display *DiagnosticHostDisplayContext) *SeatunnelErrorEventInfo
ToInfo converts one event model to response info. ToInfo 将错误事件模型转换为响应视图。
type SeatunnelErrorEventFilter ¶
type SeatunnelErrorEventFilter struct {
ErrorGroupID uint `json:"error_group_id"`
ClusterID uint `json:"cluster_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
Role string `json:"role"`
JobID string `json:"job_id"`
Keyword string `json:"keyword"`
ExceptionClass string `json:"exception_class"`
StartTime *time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
SeatunnelErrorEventFilter defines query filters for error events. SeatunnelErrorEventFilter 定义错误事件查询过滤条件。
type SeatunnelErrorEventInfo ¶
type SeatunnelErrorEventInfo struct {
ID uint `json:"id"`
ErrorGroupID uint `json:"error_group_id"`
Fingerprint string `json:"fingerprint"`
ClusterID uint `json:"cluster_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
HostName string `json:"host_name"`
HostIP string `json:"host_ip"`
AgentID string `json:"agent_id"`
Role string `json:"role"`
InstallDir string `json:"install_dir"`
SourceFile string `json:"source_file"`
SourceKind string `json:"source_kind"`
JobID string `json:"job_id"`
OccurredAt time.Time `json:"occurred_at"`
Message string `json:"message"`
ExceptionClass string `json:"exception_class"`
Evidence string `json:"evidence"`
CursorStart int64 `json:"cursor_start"`
CursorEnd int64 `json:"cursor_end"`
}
SeatunnelErrorEventInfo is the API view model for an error event. SeatunnelErrorEventInfo 是错误事件的 API 视图模型。
type SeatunnelErrorEventsData ¶
type SeatunnelErrorEventsData struct {
Items []*SeatunnelErrorEventInfo `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
SeatunnelErrorEventsData is the paginated error event payload. SeatunnelErrorEventsData 是分页错误事件载荷。
type SeatunnelErrorGroup ¶
type SeatunnelErrorGroup struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
Fingerprint string `json:"fingerprint" gorm:"size:64;uniqueIndex;not null"`
FingerprintVersion string `json:"fingerprint_version" gorm:"size:20;not null"`
Title string `json:"title" gorm:"type:text"`
ExceptionClass string `json:"exception_class" gorm:"size:255;index"`
NormalizedText string `json:"normalized_text" gorm:"type:text"`
SampleMessage string `json:"sample_message" gorm:"type:text"`
SampleEvidence string `json:"sample_evidence" gorm:"type:text"`
OccurrenceCount int64 `json:"occurrence_count" gorm:"default:0"`
FirstSeenAt time.Time `json:"first_seen_at" gorm:"index"`
LastSeenAt time.Time `json:"last_seen_at" gorm:"index"`
LastClusterID uint `json:"last_cluster_id" gorm:"index"`
LastNodeID uint `json:"last_node_id" gorm:"index"`
LastHostID uint `json:"last_host_id" gorm:"index"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
SeatunnelErrorGroup stores one aggregated error fingerprint group. SeatunnelErrorGroup 存储一个聚合后的错误指纹分组。
func (SeatunnelErrorGroup) TableName ¶
func (SeatunnelErrorGroup) TableName() string
TableName specifies the table name for SeatunnelErrorGroup. TableName 指定 SeatunnelErrorGroup 的表名。
func (*SeatunnelErrorGroup) ToInfo ¶
func (g *SeatunnelErrorGroup) ToInfo(display *DiagnosticHostDisplayContext) *SeatunnelErrorGroupInfo
ToInfo converts one group model to response info. ToInfo 将错误组模型转换为响应视图。
type SeatunnelErrorGroupDetailData ¶
type SeatunnelErrorGroupDetailData struct {
Group *SeatunnelErrorGroupInfo `json:"group"`
Events []*SeatunnelErrorEventInfo `json:"events"`
}
SeatunnelErrorGroupDetailData is the detail payload for one error group. SeatunnelErrorGroupDetailData 是单个错误组的详情载荷。
type SeatunnelErrorGroupFilter ¶
type SeatunnelErrorGroupFilter struct {
ClusterID uint `json:"cluster_id"`
NodeID uint `json:"node_id"`
HostID uint `json:"host_id"`
Role string `json:"role"`
JobID string `json:"job_id"`
Keyword string `json:"keyword"`
ExceptionClass string `json:"exception_class"`
StartTime *time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
SeatunnelErrorGroupFilter defines query filters for error groups. SeatunnelErrorGroupFilter 定义错误组查询过滤条件。
type SeatunnelErrorGroupInfo ¶
type SeatunnelErrorGroupInfo struct {
ID uint `json:"id"`
Fingerprint string `json:"fingerprint"`
FingerprintVersion string `json:"fingerprint_version"`
Title string `json:"title"`
ExceptionClass string `json:"exception_class"`
SampleMessage string `json:"sample_message"`
OccurrenceCount int64 `json:"occurrence_count"`
FirstSeenAt time.Time `json:"first_seen_at"`
LastSeenAt time.Time `json:"last_seen_at"`
LastClusterID uint `json:"last_cluster_id"`
LastNodeID uint `json:"last_node_id"`
LastHostID uint `json:"last_host_id"`
LastHostName string `json:"last_host_name"`
LastHostIP string `json:"last_host_ip"`
}
SeatunnelErrorGroupInfo is the API view model for an error group. SeatunnelErrorGroupInfo 是错误组的 API 视图模型。
type SeatunnelErrorGroupsData ¶
type SeatunnelErrorGroupsData struct {
Items []*SeatunnelErrorGroupInfo `json:"items"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"page_size"`
}
SeatunnelErrorGroupsData is the paginated error group payload. SeatunnelErrorGroupsData 是分页错误组载荷。
type SeatunnelLogCursor ¶
type SeatunnelLogCursor struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
AgentID string `json:"agent_id" gorm:"size:100;not null;uniqueIndex:idx_diag_log_cursor"`
HostID uint `json:"host_id" gorm:"index;uniqueIndex:idx_diag_log_cursor"`
ClusterID uint `json:"cluster_id" gorm:"index"`
NodeID uint `json:"node_id" gorm:"index"`
InstallDir string `json:"install_dir" gorm:"size:255;not null;uniqueIndex:idx_diag_log_cursor"`
Role string `json:"role" gorm:"size:20;not null;uniqueIndex:idx_diag_log_cursor"`
SourceFile string `json:"source_file" gorm:"size:500;not null;uniqueIndex:idx_diag_log_cursor"`
CursorOffset int64 `json:"cursor_offset"`
LastOccurredAt *time.Time `json:"last_occurred_at"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
SeatunnelLogCursor stores the latest processed file offset per source file. SeatunnelLogCursor 存储每个来源文件的最新已处理偏移量。
func (SeatunnelLogCursor) TableName ¶
func (SeatunnelLogCursor) TableName() string
TableName specifies the table name for SeatunnelLogCursor. TableName 指定 SeatunnelLogCursor 的表名。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides diagnostics workspace bootstrap data and owns the boundary between diagnostics and other runtime domains. Service 提供诊断中心初始化数据,并维护 diagnostics 与其他运行时领域之间的边界。
func NewService ¶
func NewService(clusterService *cluster.Service, monitorService *monitor.Service, monitoringService *monitoringapp.Service) *Service
NewService creates a diagnostics service using the global database when available. NewService 使用全局数据库(如果已初始化)创建诊断服务。
func NewServiceWithRepository ¶
func NewServiceWithRepository(repo *Repository, clusterService clusterReader, monitorService processEventReader, monitoringService alertInstanceReader) *Service
NewServiceWithRepository creates a diagnostics service with an explicit repository. NewServiceWithRepository 使用显式仓储创建诊断服务。
func (*Service) AppendDiagnosticStepLog ¶
func (s *Service) AppendDiagnosticStepLog(ctx context.Context, log *DiagnosticStepLog) error
AppendDiagnosticStepLog appends one diagnostics task log and publishes a streaming event. AppendDiagnosticStepLog 追加一条诊断任务日志并发布事件流更新。
func (*Service) CreateAutoPolicy ¶
func (s *Service) CreateAutoPolicy(ctx context.Context, userID uint, req *CreateInspectionAutoPolicyRequest) (*InspectionAutoPolicyInfo, error)
CreateAutoPolicy creates a new auto-inspection policy. CreateAutoPolicy 创建一条新的自动巡检策略。
func (*Service) CreateDiagnosticTask ¶
func (s *Service) CreateDiagnosticTask(ctx context.Context, req *CreateDiagnosticTaskRequest, createdBy uint, createdByName string) (*DiagnosticTask, error)
func (*Service) CreateDiagnosticTaskWithExecution ¶
func (s *Service) CreateDiagnosticTaskWithExecution(ctx context.Context, req *CreateDiagnosticTaskRequest, createdBy uint, createdByName string, request DiagnosticExecutionRequest) (*DiagnosticTask, error)
CreateDiagnosticTaskWithExecution 创建公共执行记录后创建诊断任务。 CreateDiagnosticTaskWithExecution creates a diagnostic task after creating its shared execution record.
func (*Service) DeleteAutoPolicy ¶
DeleteAutoPolicy deletes an auto-inspection policy by identifier. DeleteAutoPolicy 根据标识删除一条自动巡检策略。
func (*Service) EvaluateInspectionFindings ¶
func (s *Service) EvaluateInspectionFindings(ctx context.Context, clusterID uint, lookbackWindow time.Duration, errorThreshold int) (*InspectionEvaluationResult, error)
EvaluateInspectionFindings evaluates first-batch inspection checks using managed runtime, process events, alerts, and recent error groups. EvaluateInspectionFindings 基于受管运行时、进程事件、告警与近期错误组评估首批巡检发现项。
func (*Service) GetAutoPolicy ¶
GetAutoPolicy returns one auto-inspection policy by identifier. GetAutoPolicy 根据标识返回一条自动巡检策略。
func (*Service) GetDiagnosticTaskDetail ¶
func (s *Service) GetDiagnosticTaskDetail(ctx context.Context, taskID uint) (*DiagnosticTask, error)
GetDiagnosticTaskDetail returns one diagnostics task with related steps and node executions. GetDiagnosticTaskDetail 返回单个诊断任务及其关联步骤和节点执行。
func (*Service) GetDiagnosticTaskForActor ¶
func (s *Service) GetDiagnosticTaskForActor(ctx context.Context, actor executionapp.Actor, taskID uint) (*DiagnosticTask, error)
GetDiagnosticTaskForActor 按当前用户归属读取诊断任务。 GetDiagnosticTaskForActor loads a diagnostic task under the current user's ownership scope.
func (*Service) GetInspectionReportDetail ¶
func (s *Service) GetInspectionReportDetail(ctx context.Context, reportID uint) (*ClusterInspectionReportDetailData, error)
GetInspectionReportDetail returns one inspection report and all findings. GetInspectionReportDetail 返回单个巡检报告及其全部发现项。
func (*Service) GetSeatunnelErrorGroupDetail ¶
func (s *Service) GetSeatunnelErrorGroupDetail(ctx context.Context, filter *SeatunnelErrorEventFilter, eventLimit int) (*SeatunnelErrorGroupDetailData, error)
GetSeatunnelErrorGroupDetail returns one group and its recent events. GetSeatunnelErrorGroupDetail 返回一个错误组及其近期事件。
func (*Service) GetWorkspaceBootstrap ¶
func (s *Service) GetWorkspaceBootstrap(ctx context.Context, req *WorkspaceBootstrapRequest) (*WorkspaceBootstrapData, error)
GetWorkspaceBootstrap returns the diagnostics workspace skeleton and contextual cluster filter options. GetWorkspaceBootstrap 返回诊断中心工作台骨架及上下文集群筛选项。
func (*Service) IngestSeatunnelError ¶
func (s *Service) IngestSeatunnelError(ctx context.Context, req *IngestSeatunnelErrorRequest) error
IngestSeatunnelError persists one structured Seatunnel ERROR event and updates grouping metadata. IngestSeatunnelError 持久化一条结构化 Seatunnel ERROR 事件并更新分组元数据。
func (*Service) ListAutoPolicies ¶
func (s *Service) ListAutoPolicies(ctx context.Context, clusterID *uint, page, pageSize int) (*InspectionAutoPolicyListData, error)
ListAutoPolicies returns paginated auto-inspection policies. ListAutoPolicies 返回分页的自动巡检策略列表。
func (*Service) ListBuiltinConditionTemplates ¶
func (s *Service) ListBuiltinConditionTemplates() []*InspectionConditionTemplate
ListBuiltinConditionTemplates returns a copy of all built-in condition templates. ListBuiltinConditionTemplates 返回所有内置条件模板的副本。
func (*Service) ListDiagnosticNodeExecutions ¶
func (s *Service) ListDiagnosticNodeExecutions(ctx context.Context, taskID uint) ([]*DiagnosticNodeExecution, error)
ListDiagnosticNodeExecutions returns node executions of one diagnostics task. ListDiagnosticNodeExecutions 返回单个诊断任务的节点执行列表。
func (*Service) ListDiagnosticStepLogs ¶
func (s *Service) ListDiagnosticStepLogs(ctx context.Context, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
ListDiagnosticStepLogs lists diagnostics task logs with filters and pagination. ListDiagnosticStepLogs 按过滤条件分页查询诊断任务日志。
func (*Service) ListDiagnosticStepLogsForActor ¶
func (s *Service) ListDiagnosticStepLogsForActor(ctx context.Context, actor executionapp.Actor, filter *DiagnosticTaskLogFilter) ([]*DiagnosticStepLog, int64, error)
ListDiagnosticStepLogsForActor 在归属检查后读取诊断日志。 ListDiagnosticStepLogsForActor reads diagnostic task logs after enforcing ownership.
func (*Service) ListDiagnosticTaskSteps ¶
func (s *Service) ListDiagnosticTaskSteps(ctx context.Context, taskID uint) ([]*DiagnosticTaskStep, error)
ListDiagnosticTaskSteps returns all steps of one diagnostics task. ListDiagnosticTaskSteps 返回单个诊断任务的全部步骤。
func (*Service) ListDiagnosticTaskStepsForActor ¶
func (s *Service) ListDiagnosticTaskStepsForActor(ctx context.Context, actor executionapp.Actor, taskID uint) ([]*DiagnosticTaskStep, error)
ListDiagnosticTaskStepsForActor 在归属检查后读取诊断步骤。 ListDiagnosticTaskStepsForActor reads diagnostic task steps after enforcing ownership.
func (*Service) ListDiagnosticTasks ¶
func (s *Service) ListDiagnosticTasks(ctx context.Context, filter *DiagnosticTaskListFilter) ([]*DiagnosticTaskSummary, int64, error)
ListDiagnosticTasks returns paginated diagnostics task summaries. ListDiagnosticTasks 返回分页诊断任务摘要列表。
func (*Service) ListDiagnosticTasksForActor ¶
func (s *Service) ListDiagnosticTasksForActor(ctx context.Context, actor executionapp.Actor, filter *DiagnosticTaskListFilter) ([]*DiagnosticTaskSummary, int64, error)
ListDiagnosticTasksForActor 按当前用户归属列出诊断任务,管理员可查看全部。 ListDiagnosticTasksForActor lists diagnostic tasks owned by the current user, while administrators may view all tasks.
func (*Service) ListInspectionReports ¶
func (s *Service) ListInspectionReports(ctx context.Context, filter *ClusterInspectionReportFilter) (*ClusterInspectionReportsData, error)
ListInspectionReports returns paginated inspection reports for diagnostics workspace. ListInspectionReports 返回诊断中心的分页巡检报告列表。
func (*Service) ListLogCursorsByAgent ¶
func (s *Service) ListLogCursorsByAgent(ctx context.Context, agentID string) ([]*SeatunnelLogCursor, error)
ListLogCursorsByAgent returns all log cursors for the given agent. ListLogCursorsByAgent 返回某个 Agent 的所有日志游标。
func (*Service) ListSeatunnelErrorEvents ¶
func (s *Service) ListSeatunnelErrorEvents(ctx context.Context, filter *SeatunnelErrorEventFilter) (*SeatunnelErrorEventsData, error)
ListSeatunnelErrorEvents returns paginated error events. ListSeatunnelErrorEvents 返回分页错误事件列表。
func (*Service) ListSeatunnelErrorGroups ¶
func (s *Service) ListSeatunnelErrorGroups(ctx context.Context, filter *SeatunnelErrorGroupFilter) (*SeatunnelErrorGroupsData, error)
ListSeatunnelErrorGroups returns paginated error groups. ListSeatunnelErrorGroups 返回分页错误组列表。
func (*Service) RequestCancel ¶
func (s *Service) RequestCancel(ctx context.Context, item *executionapp.Execution, actor executionapp.Actor) (executionapp.CancelResult, error)
RequestCancel 在当前步骤结束后停止诊断任务,不中断已经发给 Agent 的命令。 RequestCancel stops a diagnostic task after the current step without interrupting a command already sent to an Agent.
func (*Service) SetAgentCommandSender ¶
func (s *Service) SetAgentCommandSender(sender diagnosticAgentCommandSender)
SetAgentCommandSender sets the optional Agent command sender used by bundle execution. SetAgentCommandSender 设置可选的 Agent 命令发送依赖,用于诊断包执行。
func (*Service) SetExecutionService ¶
func (s *Service) SetExecutionService(service *executionapp.Service)
SetExecutionService 设置诊断任务使用的公共执行服务。 SetExecutionService sets the shared execution service used by diagnostic tasks.
func (*Service) SetHostReader ¶
func (s *Service) SetHostReader(reader hostReader)
SetHostReader sets the optional host reader used to enrich diagnostic node targets. SetHostReader 设置可选的主机读取依赖,用于补全诊断节点目标的主机上下文。
func (*Service) StartAutoPolicyRuntime ¶
StartAutoPolicyRuntime starts the background evaluator for scheduled and Prometheus-backed auto policies. StartAutoPolicyRuntime 启动定时巡检与 Prometheus 自动策略的后台评估循环。
func (*Service) StartDiagnosticTask ¶
func (*Service) StartDiagnosticTaskForActor ¶
func (s *Service) StartDiagnosticTaskForActor(ctx context.Context, actor executionapp.Actor, taskID uint) error
StartDiagnosticTaskForActor 在归属检查后启动诊断任务。 StartDiagnosticTaskForActor starts a diagnostic task after enforcing ownership.
func (*Service) StartInspection ¶
func (s *Service) StartInspection(ctx context.Context, req *StartClusterInspectionRequest, requestedByUserID uint, requestedBy string) (*ClusterInspectionReportDetailData, error)
StartInspection creates one persisted inspection report, evaluates current signals, and stores the resulting findings. StartInspection 创建一条巡检报告、评估当前信号并保存巡检发现项。
func (*Service) SubscribeDiagnosticTaskEvents ¶
func (s *Service) SubscribeDiagnosticTaskEvents(taskID uint) (<-chan DiagnosticTaskEvent, func())
SubscribeDiagnosticTaskEvents subscribes to one diagnostics task event stream. SubscribeDiagnosticTaskEvents 订阅单个诊断任务的事件流。
func (*Service) UpdateAutoPolicy ¶
func (s *Service) UpdateAutoPolicy(ctx context.Context, id uint, req *UpdateInspectionAutoPolicyRequest) (*InspectionAutoPolicyInfo, error)
UpdateAutoPolicy updates an existing auto-inspection policy. UpdateAutoPolicy 更新一条已有的自动巡检策略。
func (*Service) UpdateDiagnosticNodeExecution ¶
func (s *Service) UpdateDiagnosticNodeExecution(ctx context.Context, node *DiagnosticNodeExecution) error
UpdateDiagnosticNodeExecution updates one diagnostics node execution and publishes a streaming event. UpdateDiagnosticNodeExecution 更新诊断节点执行并发布事件流更新。
func (*Service) UpdateDiagnosticTask ¶
func (s *Service) UpdateDiagnosticTask(ctx context.Context, task *DiagnosticTask) error
UpdateDiagnosticTask updates one diagnostics task and publishes a streaming event. UpdateDiagnosticTask 更新诊断任务并发布事件流更新。
func (*Service) UpdateDiagnosticTaskStep ¶
func (s *Service) UpdateDiagnosticTaskStep(ctx context.Context, step *DiagnosticTaskStep) error
UpdateDiagnosticTaskStep updates one diagnostics task step and publishes a streaming event. UpdateDiagnosticTaskStep 更新诊断任务步骤并发布事件流更新。
type StartClusterInspectionRequest ¶
type StartClusterInspectionRequest struct {
ClusterID uint `json:"cluster_id" binding:"required"`
TriggerSource InspectionTriggerSource `json:"trigger_source"`
LookbackMinutes int `json:"lookback_minutes,omitempty"`
ErrorThreshold int `json:"error_threshold,omitempty"`
}
StartClusterInspectionRequest describes one manual inspection trigger request. StartClusterInspectionRequest 描述一次手动发起巡检的请求。
type UpdateInspectionAutoPolicyRequest ¶
type UpdateInspectionAutoPolicyRequest struct {
Name *string `json:"name,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Conditions *InspectionConditionItems `json:"conditions,omitempty"`
CooldownMinutes *int `json:"cooldown_minutes,omitempty"`
AutoCreateTask *bool `json:"auto_create_task,omitempty"`
AutoStartTask *bool `json:"auto_start_task,omitempty"`
TaskOptions *DiagnosticTaskOptions `json:"task_options,omitempty"`
}
UpdateInspectionAutoPolicyRequest describes an update auto-policy request. UpdateInspectionAutoPolicyRequest 描述更新自动策略的请求。
type WorkspaceBootstrapData ¶
type WorkspaceBootstrapData struct {
GeneratedAt time.Time `json:"generated_at"`
DefaultTab WorkspaceTabKey `json:"default_tab"`
Tabs []*WorkspaceTab `json:"tabs"`
ClusterOptions []*ClusterOption `json:"cluster_options"`
EntryContext *WorkspaceContext `json:"entry_context,omitempty"`
Boundaries []*WorkspaceBoundary `json:"boundaries"`
}
WorkspaceBootstrapData is the initial payload for diagnostics workspace UI. WorkspaceBootstrapData 是诊断中心 UI 的初始化数据。
type WorkspaceBootstrapRequest ¶
WorkspaceBootstrapRequest describes the contextual query passed into the diagnostics workspace. WorkspaceBootstrapRequest 描述传入诊断工作台的上下文查询参数。
type WorkspaceBoundary ¶
type WorkspaceBoundary struct {
Key string `json:"key"`
Title string `json:"title"`
Description string `json:"description"`
}
WorkspaceBoundary documents the current diagnostics module boundaries. WorkspaceBoundary 说明当前诊断中心的模块边界。
type WorkspaceContext ¶
type WorkspaceContext struct {
ClusterID *uint `json:"cluster_id,omitempty"`
ClusterName string `json:"cluster_name,omitempty"`
Source string `json:"source,omitempty"`
AlertID string `json:"alert_id,omitempty"`
}
WorkspaceContext describes where the user navigated from. WorkspaceContext 描述用户进入诊断中心时的来源上下文。
type WorkspaceTab ¶
type WorkspaceTab struct {
Key WorkspaceTabKey `json:"key"`
Label string `json:"label"`
Description string `json:"description"`
}
WorkspaceTab describes one diagnostics tab. WorkspaceTab 描述一个诊断中心标签页。
type WorkspaceTabKey ¶
type WorkspaceTabKey string
WorkspaceTabKey identifies one diagnostics workspace tab. WorkspaceTabKey 标识诊断中心工作台中的一个标签页。
const ( // WorkspaceTabErrors is the error center tab. // WorkspaceTabErrors 表示错误中心标签页。 WorkspaceTabErrors WorkspaceTabKey = "errors" // WorkspaceTabInspections is the inspection tab. // WorkspaceTabInspections 表示巡检标签页。 WorkspaceTabInspections WorkspaceTabKey = "inspections" // WorkspaceTabTasks is the diagnostic task / bundle tab. // WorkspaceTabTasks 表示诊断任务 / 诊断包标签页。 WorkspaceTabTasks WorkspaceTabKey = "tasks" )
Source Files
¶
- auto_policy_checker.go
- auto_policy_models.go
- auto_policy_repository.go
- auto_policy_runtime.go
- auto_policy_service.go
- display_text.go
- err.go
- error_models.go
- execution.go
- handler.go
- inspection_models.go
- inspection_report_service.go
- inspection_service.go
- localization.go
- model.go
- normalize.go
- repository.go
- service.go
- task_event_stream.go
- task_execute.go
- task_models.go
- task_repository.go
- task_service.go