monitoring

package
v1.0.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package monitoring provides cluster monitoring overview APIs for STX. monitoring 包为 STX 提供集群监控总览 API。

Index

Constants

View Source
const (
	// AlertRuleKeyProcessCrashed is the rule key for process crashed events.
	// AlertRuleKeyProcessCrashed 是进程崩溃规则键。
	AlertRuleKeyProcessCrashed = "process_crashed"
	// AlertRuleKeyProcessRestartFailed is the rule key for process restart failed events.
	// AlertRuleKeyProcessRestartFailed 是进程重启失败规则键。
	AlertRuleKeyProcessRestartFailed = "process_restart_failed"
	// AlertRuleKeyProcessRestartLimitReached is the rule key for process restart limit reached events.
	// AlertRuleKeyProcessRestartLimitReached 是达到重启上限规则键。
	AlertRuleKeyProcessRestartLimitReached = "process_restart_limit_reached"
	// AlertRuleKeyClusterRestartRequested is the rule key for manual restart events.
	// AlertRuleKeyClusterRestartRequested 表示手动重启事件(集群或节点)的规则键。
	AlertRuleKeyClusterRestartRequested = "cluster_restart_requested"
	// AlertRuleKeyNodeStopRequested is the rule key for manual node stop events.
	// AlertRuleKeyNodeStopRequested 表示手动节点停止事件的规则键。
	AlertRuleKeyNodeStopRequested = "node_stop_requested"
	// AlertRuleKeyNodeOffline is the rule key for sustained node-unavailable episodes.
	// AlertRuleKeyNodeOffline 表示节点持续不可用阶段的规则键。
	AlertRuleKeyNodeOffline = "node_offline"
)
View Source
const (
	// AlertPolicyCapabilityKeyPlatformHealth indicates platform-health based alert policies.
	// AlertPolicyCapabilityKeyPlatformHealth 表示平台健康类告警策略能力。
	AlertPolicyCapabilityKeyPlatformHealth = "platform_health"
	// AlertPolicyCapabilityKeyMetricsTemplates indicates metrics-template based policies.
	// AlertPolicyCapabilityKeyMetricsTemplates 表示指标模板类告警策略能力。
	AlertPolicyCapabilityKeyMetricsTemplates = "metrics_templates"
	// AlertPolicyCapabilityKeyCustomPromQL indicates custom PromQL policy capability.
	// AlertPolicyCapabilityKeyCustomPromQL 表示自定义 PromQL 策略能力。
	AlertPolicyCapabilityKeyCustomPromQL = "custom_promql"
	// AlertPolicyCapabilityKeyRemoteIngest indicates remote Alertmanager ingest capability.
	// AlertPolicyCapabilityKeyRemoteIngest 表示远程 Alertmanager 回流能力。
	AlertPolicyCapabilityKeyRemoteIngest = "remote_ingest"
	// AlertPolicyCapabilityKeyWebhookNotification indicates webhook/IM notification delivery capability.
	// AlertPolicyCapabilityKeyWebhookNotification 表示 Webhook/IM 通知投递能力。
	AlertPolicyCapabilityKeyWebhookNotification = "webhook_notification"
	// AlertPolicyCapabilityKeyInAppNotification indicates in-app notification center capability.
	// AlertPolicyCapabilityKeyInAppNotification 表示站内通知中心能力。
	AlertPolicyCapabilityKeyInAppNotification = "in_app_notification"
)

Variables

View Source
var (
	// ErrAlertInstanceInvalidID indicates the alert instance identifier is invalid.
	// ErrAlertInstanceInvalidID 表示告警实例标识非法。
	ErrAlertInstanceInvalidID = errors.New("monitoring: invalid alert instance id")
	// ErrAlertInstanceNotFound indicates the alert instance does not exist.
	// ErrAlertInstanceNotFound 表示告警实例不存在。
	ErrAlertInstanceNotFound = errors.New("monitoring: alert instance not found")
	// ErrAlertInstanceAlreadyClosed indicates the alert incident is already closed.
	// ErrAlertInstanceAlreadyClosed 表示该告警事件已经关闭。
	ErrAlertInstanceAlreadyClosed = errors.New("monitoring: alert instance already closed")
	// ErrAlertInstanceNotClosable indicates the alert incident is not yet recoverd and cannot be closed.
	// ErrAlertInstanceNotClosable 表示告警尚未恢复,当前不可关闭。
	ErrAlertInstanceNotClosable = errors.New("monitoring: alert instance is not closable")
)
View Source
var (
	// ErrAlertPolicyNotFound indicates the requested alert policy does not exist.
	// ErrAlertPolicyNotFound 表示请求的告警策略不存在。
	ErrAlertPolicyNotFound = errors.New("monitoring: alert policy not found")
	// ErrAlertPolicyInvalidID indicates the alert policy ID is invalid.
	// ErrAlertPolicyInvalidID 表示告警策略 ID 非法。
	ErrAlertPolicyInvalidID = errors.New("monitoring: invalid alert policy id")
	// ErrAlertPolicyInvalidClusterScope indicates the cluster scope is invalid.
	// ErrAlertPolicyInvalidClusterScope 表示策略集群作用域非法。
	ErrAlertPolicyInvalidClusterScope = errors.New("monitoring: invalid alert policy cluster scope")
	// ErrAlertPolicyClusterNotFound indicates the referenced cluster does not exist.
	// ErrAlertPolicyClusterNotFound 表示引用的集群不存在。
	ErrAlertPolicyClusterNotFound = errors.New("monitoring: alert policy cluster not found")
	// ErrAlertPolicyNotificationChannelNotFound indicates a referenced channel does not exist.
	// ErrAlertPolicyNotificationChannelNotFound 表示引用的通知渠道不存在。
	ErrAlertPolicyNotificationChannelNotFound = errors.New("monitoring: alert policy notification channel not found")
	// ErrAlertPolicyReceiverUserNotFound indicates a referenced receiver user does not exist.
	// ErrAlertPolicyReceiverUserNotFound 表示引用的通知接收用户不存在。
	ErrAlertPolicyReceiverUserNotFound = errors.New("monitoring: alert policy receiver user not found")
	// ErrAlertPolicyReceiverUserInactive indicates a referenced receiver user is inactive.
	// ErrAlertPolicyReceiverUserInactive 表示引用的通知接收用户已被禁用。
	ErrAlertPolicyReceiverUserInactive = errors.New("monitoring: alert policy receiver user inactive")
	// ErrAlertPolicyReceiverUserEmailMissing indicates a referenced receiver user has no valid email.
	// ErrAlertPolicyReceiverUserEmailMissing 表示引用的通知接收用户未配置有效邮箱。
	ErrAlertPolicyReceiverUserEmailMissing = errors.New("monitoring: alert policy receiver user email missing")
	// ErrAlertPolicyUnsupportedTemplate indicates the template key is unknown.
	// ErrAlertPolicyUnsupportedTemplate 表示模板键不存在。
	ErrAlertPolicyUnsupportedTemplate = errors.New("monitoring: unsupported alert policy template")
	// ErrAlertPolicyTemplateTypeMismatch indicates the template does not match the policy type.
	// ErrAlertPolicyTemplateTypeMismatch 表示模板与策略类型不匹配。
	ErrAlertPolicyTemplateTypeMismatch = errors.New("monitoring: alert policy template type mismatch")
	// ErrAlertPolicyLegacyBridgeRequiresClusterScope indicates a legacy-backed policy must target one cluster.
	// ErrAlertPolicyLegacyBridgeRequiresClusterScope 表示旧规则桥接策略必须绑定具体集群。
	ErrAlertPolicyLegacyBridgeRequiresClusterScope = errors.New("monitoring: legacy-backed policy requires concrete cluster scope")
	// ErrAlertPolicyLegacyRuleUnsupported indicates the referenced legacy rule bridge target is unsupported.
	// ErrAlertPolicyLegacyRuleUnsupported 表示引用的旧规则桥接目标不受支持。
	ErrAlertPolicyLegacyRuleUnsupported = errors.New("monitoring: unsupported legacy rule bridge")
	// ErrAlertPolicyLegacyBridgeConflict indicates another policy already bridges the same legacy rule.
	// ErrAlertPolicyLegacyBridgeConflict 表示已有其他策略桥接到同一条旧规则。
	ErrAlertPolicyLegacyBridgeConflict = errors.New("monitoring: duplicate legacy rule bridge policy")
)

Functions

This section is empty.

Types

type AcknowledgeAlertRequest

type AcknowledgeAlertRequest struct {
	Note string `json:"note"`
}

AcknowledgeAlertRequest represents acknowledge action payload. AcknowledgeAlertRequest 表示确认告警请求。

type AlertActionResult

type AlertActionResult struct {
	EventID          uint        `json:"event_id"`
	Status           AlertStatus `json:"status"`
	AcknowledgedBy   string      `json:"acknowledged_by,omitempty"`
	AcknowledgedAt   *time.Time  `json:"acknowledged_at,omitempty"`
	SilencedBy       string      `json:"silenced_by,omitempty"`
	SilencedUntil    *time.Time  `json:"silenced_until,omitempty"`
	LatestActionNote string      `json:"latest_action_note,omitempty"`
}

AlertActionResult represents action result on one alert. AlertActionResult 表示单条告警动作执行结果。

type AlertDisplayStatus

type AlertDisplayStatus string

AlertDisplayStatus represents the user-facing alert state in alert center. AlertDisplayStatus 表示告警中心面向用户展示的主状态。

const (
	// AlertDisplayStatusFiring indicates the problem still exists.
	// AlertDisplayStatusFiring 表示问题仍然存在。
	AlertDisplayStatusFiring AlertDisplayStatus = "firing"
	// AlertDisplayStatusResolved indicates the problem has recovered.
	// AlertDisplayStatusResolved 表示问题已经恢复。
	AlertDisplayStatusResolved AlertDisplayStatus = "resolved"
	// AlertDisplayStatusClosed indicates the alert incident is manually closed.
	// AlertDisplayStatusClosed 表示该次告警事件已被人工关闭。
	AlertDisplayStatusClosed AlertDisplayStatus = "closed"
)

type AlertEvent

type AlertEvent struct {
	AlertID          string                   `json:"alert_id"`
	EventID          uint                     `json:"event_id"`
	ClusterID        uint                     `json:"cluster_id"`
	ClusterName      string                   `json:"cluster_name"`
	NodeID           uint                     `json:"node_id"`
	HostID           uint                     `json:"host_id"`
	Hostname         string                   `json:"hostname"`
	IP               string                   `json:"ip"`
	EventType        monitor.ProcessEventType `json:"event_type"`
	Severity         AlertSeverity            `json:"severity"`
	Status           AlertStatus              `json:"status"`
	RuleKey          string                   `json:"rule_key"`
	RuleName         string                   `json:"rule_name"`
	ProcessName      string                   `json:"process_name"`
	PID              int                      `json:"pid"`
	Role             string                   `json:"role"`
	Details          string                   `json:"details"`
	CreatedAt        time.Time                `json:"created_at"`
	AcknowledgedBy   string                   `json:"acknowledged_by,omitempty"`
	AcknowledgedAt   *time.Time               `json:"acknowledged_at,omitempty"`
	SilencedBy       string                   `json:"silenced_by,omitempty"`
	SilencedUntil    *time.Time               `json:"silenced_until,omitempty"`
	LatestActionNote string                   `json:"latest_action_note,omitempty"`
}

AlertEvent represents one alert item in alert center. AlertEvent 表示告警中心中的单条告警记录。

type AlertEventQueryFilter

type AlertEventQueryFilter struct {
	ClusterID uint
	StartTime *time.Time
	EndTime   *time.Time
	Page      int
	PageSize  int
}

AlertEventQueryFilter defines query options for alert events. AlertEventQueryFilter 定义告警事件查询条件。

type AlertEventSource

type AlertEventSource struct {
	ID          uint                     `json:"id"`
	ClusterID   uint                     `json:"cluster_id"`
	ClusterName string                   `json:"cluster_name"`
	NodeID      uint                     `json:"node_id"`
	HostID      uint                     `json:"host_id"`
	EventType   monitor.ProcessEventType `json:"event_type"`
	PID         int                      `json:"pid"`
	ProcessName string                   `json:"process_name"`
	InstallDir  string                   `json:"install_dir"`
	Role        string                   `json:"role"`
	Details     string                   `json:"details"`
	CreatedAt   time.Time                `json:"created_at"`
	Hostname    string                   `json:"hostname"`
	IP          string                   `json:"ip"`
}

AlertEventSource represents joined alert event rows from DB. AlertEventSource 表示从 DB 联表查询出的告警事件记录。

type AlertEventState

type AlertEventState struct {
	ID             uint        `json:"id" gorm:"primaryKey;autoIncrement"`
	EventID        uint        `json:"event_id" gorm:"not null;uniqueIndex"`
	ClusterID      uint        `json:"cluster_id" gorm:"not null;index"`
	Status         AlertStatus `json:"status" gorm:"size:20;not null;index"`
	AcknowledgedBy string      `json:"acknowledged_by" gorm:"size:100"`
	AcknowledgedAt *time.Time  `json:"acknowledged_at"`
	SilencedBy     string      `json:"silenced_by" gorm:"size:100"`
	SilencedUntil  *time.Time  `json:"silenced_until" gorm:"index"`
	Note           string      `json:"note" gorm:"type:text"`
	CreatedAt      time.Time   `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt      time.Time   `json:"updated_at" gorm:"autoUpdateTime"`
}

AlertEventState records manual state operations for one process event. AlertEventState 记录针对单条进程事件的人工操作状态。

func (AlertEventState) TableName

func (AlertEventState) TableName() string

TableName specifies the table name for AlertEventState. TableName 指定 AlertEventState 表名。

type AlertFilter

type AlertFilter struct {
	ClusterID uint        `json:"cluster_id"`
	Status    AlertStatus `json:"status"`
	StartTime *time.Time  `json:"start_time"`
	EndTime   *time.Time  `json:"end_time"`
	Page      int         `json:"page"`
	PageSize  int         `json:"page_size"`
}

AlertFilter represents query filters for alert list. AlertFilter 表示告警列表查询过滤条件。

type AlertHandlingStatus

type AlertHandlingStatus string

AlertHandlingStatus represents manual handling state over a unified alert. AlertHandlingStatus 表示统一告警上的人工处理状态。

const (
	// AlertHandlingStatusPending indicates no manual handling is applied.
	// AlertHandlingStatusPending 表示尚未进行人工处理。
	AlertHandlingStatusPending AlertHandlingStatus = "pending"
	// AlertHandlingStatusAcknowledged indicates alert has been acknowledged.
	// AlertHandlingStatusAcknowledged 表示告警已确认。
	AlertHandlingStatusAcknowledged AlertHandlingStatus = "acknowledged"
	// AlertHandlingStatusSilenced indicates alert is temporarily silenced.
	// AlertHandlingStatusSilenced 表示告警已静默。
	AlertHandlingStatusSilenced AlertHandlingStatus = "silenced"
	// AlertHandlingStatusClosed indicates the alert incident is manually closed.
	// AlertHandlingStatusClosed 表示告警事件已被人工关闭。
	AlertHandlingStatusClosed AlertHandlingStatus = "closed"
)

type AlertInstance

type AlertInstance struct {
	AlertID         string                  `json:"alert_id"`
	SourceType      AlertSourceType         `json:"source_type"`
	ClusterID       string                  `json:"cluster_id"`
	ClusterName     string                  `json:"cluster_name"`
	Severity        AlertSeverity           `json:"severity"`
	AlertName       string                  `json:"alert_name"`
	RuleKey         string                  `json:"rule_key"`
	Summary         string                  `json:"summary"`
	Description     string                  `json:"description"`
	Status          AlertDisplayStatus      `json:"status"`
	LifecycleStatus AlertLifecycleStatus    `json:"lifecycle_status"`
	HandlingStatus  AlertHandlingStatus     `json:"handling_status"`
	CreatedAt       time.Time               `json:"created_at"`
	FiringAt        time.Time               `json:"firing_at"`
	ResolvedAt      *time.Time              `json:"resolved_at,omitempty"`
	LastSeenAt      time.Time               `json:"last_seen_at"`
	AcknowledgedBy  string                  `json:"acknowledged_by,omitempty"`
	AcknowledgedAt  *time.Time              `json:"acknowledged_at,omitempty"`
	SilencedBy      string                  `json:"silenced_by,omitempty"`
	SilencedUntil   *time.Time              `json:"silenced_until,omitempty"`
	ClosedBy        string                  `json:"closed_by,omitempty"`
	ClosedAt        *time.Time              `json:"closed_at,omitempty"`
	LatestNote      string                  `json:"latest_note,omitempty"`
	SourceRef       *AlertInstanceSourceRef `json:"source_ref,omitempty"`
}

AlertInstance represents one normalized alert item for frontend. AlertInstance 表示返回给前端的统一告警项。

type AlertInstanceActionResult

type AlertInstanceActionResult struct {
	AlertID        string              `json:"alert_id"`
	Status         AlertDisplayStatus  `json:"status,omitempty"`
	HandlingStatus AlertHandlingStatus `json:"handling_status"`
	AcknowledgedBy string              `json:"acknowledged_by,omitempty"`
	AcknowledgedAt *time.Time          `json:"acknowledged_at,omitempty"`
	SilencedBy     string              `json:"silenced_by,omitempty"`
	SilencedUntil  *time.Time          `json:"silenced_until,omitempty"`
	ClosedBy       string              `json:"closed_by,omitempty"`
	ClosedAt       *time.Time          `json:"closed_at,omitempty"`
	LatestNote     string              `json:"latest_note,omitempty"`
}

AlertInstanceActionResult represents action result on one unified alert instance. AlertInstanceActionResult 表示统一告警实例上的动作结果。

type AlertInstanceFilter

type AlertInstanceFilter struct {
	SourceType      AlertSourceType      `json:"source_type"`
	ClusterID       string               `json:"cluster_id"`
	Severity        AlertSeverity        `json:"severity"`
	Status          AlertDisplayStatus   `json:"status"`
	LifecycleStatus AlertLifecycleStatus `json:"lifecycle_status"`
	HandlingStatus  AlertHandlingStatus  `json:"handling_status"`
	StartTime       *time.Time           `json:"start_time"`
	EndTime         *time.Time           `json:"end_time"`
	Page            int                  `json:"page"`
	PageSize        int                  `json:"page_size"`
}

AlertInstanceFilter represents filters for unified alert instances. AlertInstanceFilter 表示统一告警实例查询过滤条件。

type AlertInstanceListData

type AlertInstanceListData struct {
	GeneratedAt time.Time           `json:"generated_at"`
	Page        int                 `json:"page"`
	PageSize    int                 `json:"page_size"`
	Total       int64               `json:"total"`
	Stats       *AlertInstanceStats `json:"stats"`
	Alerts      []*AlertInstance    `json:"alerts"`
}

AlertInstanceListData represents unified alert list response payload. AlertInstanceListData 表示统一告警列表响应数据。

type AlertInstanceSourceRef

type AlertInstanceSourceRef struct {
	EventID     uint   `json:"event_id,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	EventType   string `json:"event_type,omitempty"`
	ProcessName string `json:"process_name,omitempty"`
	Hostname    string `json:"hostname,omitempty"`
	Receiver    string `json:"receiver,omitempty"`
	Env         string `json:"env,omitempty"`
}

AlertInstanceSourceRef contains original-source reference info for one alert. AlertInstanceSourceRef 表示统一告警关联的原始来源信息。

type AlertInstanceStats

type AlertInstanceStats struct {
	Firing   int64 `json:"firing"`
	Resolved int64 `json:"resolved"`
	Closed   int64 `json:"closed"`
}

AlertInstanceStats summarizes unified alert counts. AlertInstanceStats 汇总统一告警数量统计。

type AlertLifecycleStatus

type AlertLifecycleStatus string

AlertLifecycleStatus represents the source alert lifecycle. AlertLifecycleStatus 表示源告警生命周期状态。

const (
	// AlertLifecycleStatusFiring indicates alert is currently firing.
	// AlertLifecycleStatusFiring 表示告警正在触发。
	AlertLifecycleStatusFiring AlertLifecycleStatus = "firing"
	// AlertLifecycleStatusResolved indicates alert is resolved.
	// AlertLifecycleStatusResolved 表示告警已恢复。
	AlertLifecycleStatusResolved AlertLifecycleStatus = "resolved"
)

type AlertListData

type AlertListData struct {
	GeneratedAt time.Time     `json:"generated_at"`
	Page        int           `json:"page"`
	PageSize    int           `json:"page_size"`
	Total       int64         `json:"total"`
	Stats       *AlertStats   `json:"stats"`
	Alerts      []*AlertEvent `json:"alerts"`
}

AlertListData represents alert center list payload. AlertListData 表示告警中心列表响应数据。

type AlertPolicy

type AlertPolicy struct {
	ID                         uint                       `json:"id" gorm:"primaryKey;autoIncrement"`
	Name                       string                     `json:"name" gorm:"size:160;not null;index"`
	Description                string                     `json:"description" gorm:"type:text"`
	PolicyType                 AlertPolicyBuilderKind     `json:"policy_type" gorm:"size:40;not null;index"`
	TemplateKey                string                     `json:"template_key" gorm:"size:120;index"`
	LegacyRuleKey              string                     `json:"legacy_rule_key" gorm:"size:120;index"`
	ClusterID                  string                     `json:"cluster_id" gorm:"size:64;index"`
	Severity                   AlertSeverity              `json:"severity" gorm:"size:20;default:warning"`
	Enabled                    bool                       `json:"enabled" gorm:"default:true"`
	CooldownMinutes            int                        `json:"cooldown_minutes" gorm:"default:0"`
	SendRecovery               bool                       `json:"send_recovery" gorm:"default:true"`
	PromQL                     string                     `json:"promql" gorm:"type:text"`
	ConditionsJSON             string                     `json:"conditions_json" gorm:"type:text"`
	NotificationChannelIDsJSON string                     `json:"notification_channel_ids_json" gorm:"type:text"`
	ReceiverUserIDsJSON        string                     `json:"receiver_user_ids_json" gorm:"type:text"`
	MatchCount                 int                        `json:"match_count" gorm:"default:0"`
	DeliveryCount              int                        `json:"delivery_count" gorm:"default:0"`
	LastMatchedAt              *time.Time                 `json:"last_matched_at"`
	LastDeliveredAt            *time.Time                 `json:"last_delivered_at"`
	LastExecutionStatus        AlertPolicyExecutionStatus `json:"last_execution_status" gorm:"size:20;default:idle"`
	LastExecutionError         string                     `json:"last_execution_error" gorm:"type:text"`
	CreatedAt                  time.Time                  `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt                  time.Time                  `json:"updated_at" gorm:"autoUpdateTime"`
}

AlertPolicy represents one unified alert policy resource skeleton. AlertPolicy 表示统一告警策略资源骨架。

func (AlertPolicy) TableName

func (AlertPolicy) TableName() string

TableName specifies the table name for AlertPolicy. TableName 指定 AlertPolicy 表名。

type AlertPolicyBuilderDTO

type AlertPolicyBuilderDTO struct {
	Key           AlertPolicyBuilderKind      `json:"key"`
	Title         string                      `json:"title"`
	Description   string                      `json:"description"`
	Status        AlertPolicyCapabilityStatus `json:"status"`
	CapabilityKey string                      `json:"capability_key"`
	Recommended   bool                        `json:"recommended"`
}

AlertPolicyBuilderDTO represents one builder entry in the policy center. AlertPolicyBuilderDTO 表示策略中心中的构建器入口。

type AlertPolicyBuilderKind

type AlertPolicyBuilderKind string

AlertPolicyBuilderKind represents one policy-builder experience in UI. AlertPolicyBuilderKind 表示前端策略构建器类型。

const (
	// AlertPolicyBuilderKindPlatformHealth represents platform-health policy builder.
	// AlertPolicyBuilderKindPlatformHealth 表示平台健康策略构建器。
	AlertPolicyBuilderKindPlatformHealth AlertPolicyBuilderKind = "platform_health"
	// AlertPolicyBuilderKindMetricsTemplate represents metrics-template policy builder.
	// AlertPolicyBuilderKindMetricsTemplate 表示指标模板策略构建器。
	AlertPolicyBuilderKindMetricsTemplate AlertPolicyBuilderKind = "metrics_template"
	// AlertPolicyBuilderKindCustomPromQL represents custom PromQL policy builder.
	// AlertPolicyBuilderKindCustomPromQL 表示自定义 PromQL 策略构建器。
	AlertPolicyBuilderKindCustomPromQL AlertPolicyBuilderKind = "custom_promql"
)

type AlertPolicyCapabilityDTO

type AlertPolicyCapabilityDTO struct {
	Key       string                      `json:"key"`
	Title     string                      `json:"title"`
	Summary   string                      `json:"summary"`
	Status    AlertPolicyCapabilityStatus `json:"status"`
	Reason    string                      `json:"reason,omitempty"`
	DependsOn []string                    `json:"depends_on,omitempty"`
}

AlertPolicyCapabilityDTO represents one capability card in the unified policy center. AlertPolicyCapabilityDTO 表示统一策略中心中的能力卡片。

type AlertPolicyCapabilityStatus

type AlertPolicyCapabilityStatus string

AlertPolicyCapabilityStatus represents one capability state in policy center. AlertPolicyCapabilityStatus 表示策略中心中的一项能力状态。

const (
	// AlertPolicyCapabilityStatusAvailable indicates capability is ready to use.
	// AlertPolicyCapabilityStatusAvailable 表示能力已可用。
	AlertPolicyCapabilityStatusAvailable AlertPolicyCapabilityStatus = "available"
	// AlertPolicyCapabilityStatusUnavailable indicates capability is currently unavailable.
	// AlertPolicyCapabilityStatusUnavailable 表示能力当前不可用。
	AlertPolicyCapabilityStatusUnavailable AlertPolicyCapabilityStatus = "unavailable"
	// AlertPolicyCapabilityStatusPlanned indicates capability is planned but not implemented yet.
	// AlertPolicyCapabilityStatusPlanned 表示能力已规划但尚未实现。
	AlertPolicyCapabilityStatusPlanned AlertPolicyCapabilityStatus = "planned"
)

type AlertPolicyCenterBootstrapData

type AlertPolicyCenterBootstrapData struct {
	GeneratedAt            time.Time                        `json:"generated_at"`
	CapabilityMode         string                           `json:"capability_mode"`
	Capabilities           []*AlertPolicyCapabilityDTO      `json:"capabilities"`
	Builders               []*AlertPolicyBuilderDTO         `json:"builders"`
	Templates              []*AlertPolicyTemplateSummaryDTO `json:"templates"`
	Components             []*IntegrationComponentStatus    `json:"components"`
	NotifiableUsers        []*NotificationRecipientUserDTO  `json:"notifiable_users"`
	DefaultReceiverUserIDs []uint64                         `json:"default_receiver_user_ids"`
}

AlertPolicyCenterBootstrapData represents bootstrap payload for unified policy center. AlertPolicyCenterBootstrapData 表示统一策略中心的初始化数据。

type AlertPolicyConditionDTO

type AlertPolicyConditionDTO struct {
	MetricKey     string `json:"metric_key"`
	Operator      string `json:"operator"`
	Threshold     string `json:"threshold"`
	WindowMinutes int    `json:"window_minutes"`
}

AlertPolicyConditionDTO represents one condition item in a persisted alert policy. AlertPolicyConditionDTO 表示持久化告警策略中的一条条件项。

type AlertPolicyDTO

type AlertPolicyDTO struct {
	ID                     uint                       `json:"id"`
	Name                   string                     `json:"name"`
	Description            string                     `json:"description"`
	PolicyType             AlertPolicyBuilderKind     `json:"policy_type"`
	TemplateKey            string                     `json:"template_key,omitempty"`
	LegacyRuleKey          string                     `json:"legacy_rule_key,omitempty"`
	ClusterID              string                     `json:"cluster_id,omitempty"`
	Severity               AlertSeverity              `json:"severity"`
	Enabled                bool                       `json:"enabled"`
	CooldownMinutes        int                        `json:"cooldown_minutes"`
	SendRecovery           bool                       `json:"send_recovery"`
	PromQL                 string                     `json:"promql,omitempty"`
	Conditions             []*AlertPolicyConditionDTO `json:"conditions"`
	NotificationChannelIDs []uint                     `json:"notification_channel_ids"`
	ReceiverUserIDs        []uint64                   `json:"receiver_user_ids"`
	MatchCount             int                        `json:"match_count"`
	DeliveryCount          int                        `json:"delivery_count"`
	LastMatchedAt          *time.Time                 `json:"last_matched_at,omitempty"`
	LastDeliveredAt        *time.Time                 `json:"last_delivered_at,omitempty"`
	LastExecutionStatus    AlertPolicyExecutionStatus `json:"last_execution_status"`
	LastExecutionError     string                     `json:"last_execution_error,omitempty"`
	CreatedAt              time.Time                  `json:"created_at"`
	UpdatedAt              time.Time                  `json:"updated_at"`
}

AlertPolicyDTO represents one unified alert policy resource for frontend. AlertPolicyDTO 表示前端使用的统一告警策略资源。

type AlertPolicyExecutionStateUpdate

type AlertPolicyExecutionStateUpdate struct {
	MatchCountDelta     int
	DeliveryCountDelta  int
	LastMatchedAt       *time.Time
	LastDeliveredAt     *time.Time
	LastExecutionStatus AlertPolicyExecutionStatus
	LastExecutionError  string
}

AlertPolicyExecutionStateUpdate describes aggregate execution changes for one policy. AlertPolicyExecutionStateUpdate 描述单条策略的一次执行聚合更新。

type AlertPolicyExecutionStatus

type AlertPolicyExecutionStatus string

AlertPolicyExecutionStatus represents the latest execution result of one unified alert policy. AlertPolicyExecutionStatus 表示统一告警策略最近一次执行结果。

const (
	// AlertPolicyExecutionStatusIdle indicates the policy has not matched any event yet.
	// AlertPolicyExecutionStatusIdle 表示策略尚未匹配到任何事件。
	AlertPolicyExecutionStatusIdle AlertPolicyExecutionStatus = "idle"
	// AlertPolicyExecutionStatusMatched indicates the policy matched but no delivery was executed.
	// AlertPolicyExecutionStatusMatched 表示策略已匹配但尚未执行通知投递。
	AlertPolicyExecutionStatusMatched AlertPolicyExecutionStatus = "matched"
	// AlertPolicyExecutionStatusSent indicates every attempted delivery succeeded or was already deduplicated as sent.
	// AlertPolicyExecutionStatusSent 表示本次执行的通知已成功发送或已被去重识别为已发送。
	AlertPolicyExecutionStatusSent AlertPolicyExecutionStatus = "sent"
	// AlertPolicyExecutionStatusFailed indicates every attempted delivery failed.
	// AlertPolicyExecutionStatusFailed 表示本次执行的通知全部失败。
	AlertPolicyExecutionStatusFailed AlertPolicyExecutionStatus = "failed"
	// AlertPolicyExecutionStatusPartial indicates some deliveries succeeded while others failed.
	// AlertPolicyExecutionStatusPartial 表示本次执行的通知部分成功、部分失败。
	AlertPolicyExecutionStatusPartial AlertPolicyExecutionStatus = "partial"
)

type AlertPolicyListData

type AlertPolicyListData struct {
	GeneratedAt time.Time         `json:"generated_at"`
	Total       int               `json:"total"`
	Policies    []*AlertPolicyDTO `json:"policies"`
}

AlertPolicyListData represents alert policy list payload. AlertPolicyListData 表示告警策略列表响应数据。

type AlertPolicyTemplateSummaryDTO

type AlertPolicyTemplateSummaryDTO struct {
	Key               string   `json:"key"`
	Name              string   `json:"name"`
	Description       string   `json:"description"`
	Category          string   `json:"category"`
	SourceKind        string   `json:"source_kind"`
	CapabilityKey     string   `json:"capability_key"`
	LegacyRuleKey     string   `json:"legacy_rule_key,omitempty"`
	MetricSource      string   `json:"metric_source,omitempty"`
	RequiredSignals   []string `json:"required_signals,omitempty"`
	SuggestedPromQL   string   `json:"suggested_promql,omitempty"`
	DefaultOperator   string   `json:"default_operator,omitempty"`
	DefaultThreshold  string   `json:"default_threshold,omitempty"`
	DefaultWindowMins int      `json:"default_window_minutes,omitempty"`
	Recommended       bool     `json:"recommended"`
}

AlertPolicyTemplateSummaryDTO represents one recommended policy template summary. AlertPolicyTemplateSummaryDTO 表示一条推荐策略模板摘要。

type AlertRule

type AlertRule struct {
	ID            uint          `json:"id" gorm:"primaryKey;autoIncrement"`
	ClusterID     uint          `json:"cluster_id" gorm:"not null;index;uniqueIndex:ux_monitoring_cluster_rule"`
	RuleKey       string        `json:"rule_key" gorm:"size:80;not null;uniqueIndex:ux_monitoring_cluster_rule"`
	RuleName      string        `json:"rule_name" gorm:"size:120;not null"`
	Description   string        `json:"description" gorm:"type:text"`
	Severity      AlertSeverity `json:"severity" gorm:"size:20;default:warning"`
	Enabled       bool          `json:"enabled" gorm:"default:true"`
	Threshold     int           `json:"threshold" gorm:"default:1"`
	WindowSeconds int           `json:"window_seconds" gorm:"default:300"`
	CreatedAt     time.Time     `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt     time.Time     `json:"updated_at" gorm:"autoUpdateTime"`
}

AlertRule represents persistent alert rule configuration. AlertRule 表示持久化的告警规则配置。

func (AlertRule) TableName

func (AlertRule) TableName() string

TableName specifies the table name for AlertRule. TableName 指定 AlertRule 表名。

type AlertRuleDTO

type AlertRuleDTO struct {
	ID            uint          `json:"id"`
	ClusterID     uint          `json:"cluster_id"`
	RuleKey       string        `json:"rule_key"`
	RuleName      string        `json:"rule_name"`
	Description   string        `json:"description"`
	Severity      AlertSeverity `json:"severity"`
	Enabled       bool          `json:"enabled"`
	Threshold     int           `json:"threshold"`
	WindowSeconds int           `json:"window_seconds"`
	CreatedAt     time.Time     `json:"created_at"`
	UpdatedAt     time.Time     `json:"updated_at"`
}

AlertRuleDTO represents a monitoring alert rule for frontend. AlertRuleDTO 表示前端可消费的告警规则。

type AlertRuleListData

type AlertRuleListData struct {
	GeneratedAt time.Time       `json:"generated_at"`
	ClusterID   uint            `json:"cluster_id"`
	Rules       []*AlertRuleDTO `json:"rules"`
}

AlertRuleListData represents rule list payload. AlertRuleListData 表示规则列表响应数据。

type AlertSeverity

type AlertSeverity string

AlertSeverity represents alert severity level. AlertSeverity 表示告警严重级别。

const (
	// AlertSeverityWarning indicates warning-level alerts.
	// AlertSeverityWarning 表示告警级别为 warning。
	AlertSeverityWarning AlertSeverity = "warning"
	// AlertSeverityCritical indicates critical-level alerts.
	// AlertSeverityCritical 表示告警级别为 critical。
	AlertSeverityCritical AlertSeverity = "critical"
)

type AlertSourceType

type AlertSourceType string

AlertSourceType represents where one unified alert comes from. AlertSourceType 表示统一告警的来源类型。

const (
	// AlertSourceTypeLocalProcessEvent indicates a locally detected process event.
	// AlertSourceTypeLocalProcessEvent 表示本地进程事件告警。
	AlertSourceTypeLocalProcessEvent AlertSourceType = "local_process_event"
	// AlertSourceTypeRemoteAlertmanager indicates a remote alert ingested from Alertmanager.
	// AlertSourceTypeRemoteAlertmanager 表示从 Alertmanager 回流的远程告警。
	AlertSourceTypeRemoteAlertmanager AlertSourceType = "remote_alertmanager"
)

type AlertState

type AlertState struct {
	ID             uint                `json:"id" gorm:"primaryKey;autoIncrement"`
	SourceType     AlertSourceType     `json:"source_type" gorm:"size:40;not null;index"`
	SourceKey      string              `json:"source_key" gorm:"size:255;not null;uniqueIndex"`
	ClusterID      string              `json:"cluster_id" gorm:"size:64;index"`
	HandlingStatus AlertHandlingStatus `json:"handling_status" gorm:"size:20;not null;index"`
	AcknowledgedBy string              `json:"acknowledged_by" gorm:"size:100"`
	AcknowledgedAt *time.Time          `json:"acknowledged_at"`
	SilencedBy     string              `json:"silenced_by" gorm:"size:100"`
	SilencedUntil  *time.Time          `json:"silenced_until" gorm:"index"`
	ClosedBy       string              `json:"closed_by" gorm:"size:100"`
	ClosedAt       *time.Time          `json:"closed_at" gorm:"index"`
	Note           string              `json:"note" gorm:"type:text"`
	CreatedAt      time.Time           `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt      time.Time           `json:"updated_at" gorm:"autoUpdateTime"`
}

AlertState records unified manual handling state for one alert instance. AlertState 记录统一告警实例的人工处理状态。

func (AlertState) TableName

func (AlertState) TableName() string

TableName specifies the table name for AlertState. TableName 指定 AlertState 表名。

type AlertStats

type AlertStats struct {
	Firing       int64 `json:"firing"`
	Acknowledged int64 `json:"acknowledged"`
	Silenced     int64 `json:"silenced"`
}

AlertStats summarizes alert status counts in current query result. AlertStats 汇总当前查询结果的告警状态数量。

type AlertStatus

type AlertStatus string

AlertStatus represents alert lifecycle state. AlertStatus 表示告警生命周期状态。

const (
	// AlertStatusFiring indicates the alert is currently active.
	// AlertStatusFiring 表示告警正在触发。
	AlertStatusFiring AlertStatus = "firing"
	// AlertStatusAcknowledged indicates the alert has been acknowledged.
	// AlertStatusAcknowledged 表示告警已确认。
	AlertStatusAcknowledged AlertStatus = "acknowledged"
	// AlertStatusSilenced indicates the alert is temporarily silenced.
	// AlertStatusSilenced 表示告警处于静默状态。
	AlertStatusSilenced AlertStatus = "silenced"
)

type AlertmanagerWebhookPayload

type AlertmanagerWebhookPayload struct {
	Version           string            `json:"version"`
	GroupKey          string            `json:"groupKey"`
	Status            string            `json:"status"`
	Receiver          string            `json:"receiver"`
	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`
	ExternalURL       string            `json:"externalURL"`
	Alerts            []*WebhookAlert   `json:"alerts"`
}

AlertmanagerWebhookPayload represents Alertmanager webhook body. AlertmanagerWebhookPayload 表示 Alertmanager webhook 请求体。

type AlertmanagerWebhookResult

type AlertmanagerWebhookResult struct {
	Received int      `json:"received"`
	Stored   int      `json:"stored"`
	Errors   []string `json:"errors,omitempty"`
}

AlertmanagerWebhookResult represents processing result for one webhook request. AlertmanagerWebhookResult 表示单次 webhook 处理结果。

type ClusterBaseInfo

type ClusterBaseInfo struct {
	ClusterID    uint   `json:"cluster_id"`
	ClusterName  string `json:"cluster_name"`
	Status       string `json:"status"`
	HealthStatus string `json:"health_status"`
}

ClusterBaseInfo represents basic cluster status in detail API. ClusterBaseInfo 表示集群详情中的基础状态。

type ClusterDetailStats

type ClusterDetailStats struct {
	TotalNodes             int   `json:"total_nodes"`
	OnlineNodes            int   `json:"online_nodes"`
	OfflineNodes           int   `json:"offline_nodes"`
	CrashedEvents24h       int64 `json:"crashed_events_24h"`
	RestartFailedEvents24h int64 `json:"restart_failed_events_24h"`
	ActiveAlerts1h         int64 `json:"active_alerts_1h"`
}

ClusterDetailStats represents monitoring stats for one cluster. ClusterDetailStats 表示单集群监控统计。

type ClusterHealthData

type ClusterHealthData struct {
	GeneratedAt time.Time            `json:"generated_at"`
	Total       int                  `json:"total"`
	Clusters    []*ClusterHealthItem `json:"clusters"`
}

ClusterHealthData represents all clusters health payload. ClusterHealthData 表示全部集群健康响应数据。

type ClusterHealthItem

type ClusterHealthItem struct {
	ClusterID      uint   `json:"cluster_id"`
	ClusterName    string `json:"cluster_name"`
	Status         string `json:"status"`
	HealthStatus   string `json:"health_status"`
	TotalNodes     int    `json:"total_nodes"`
	OnlineNodes    int    `json:"online_nodes"`
	OfflineNodes   int    `json:"offline_nodes"`
	ActiveAlerts   int64  `json:"active_alerts"`
	CriticalAlerts int64  `json:"critical_alerts"`
}

ClusterHealthItem represents one cluster health summary for monitoring center. ClusterHealthItem 表示监控中心中的单集群健康摘要。

type ClusterMonitoringSummary

type ClusterMonitoringSummary struct {
	ClusterID              uint       `json:"cluster_id"`
	ClusterName            string     `json:"cluster_name"`
	Status                 string     `json:"status"`
	HealthStatus           string     `json:"health_status"`
	TotalNodes             int        `json:"total_nodes"`
	OnlineNodes            int        `json:"online_nodes"`
	OfflineNodes           int        `json:"offline_nodes"`
	CrashedEvents24h       int64      `json:"crashed_events_24h"`
	RestartFailedEvents24h int64      `json:"restart_failed_events_24h"`
	ActiveAlerts1h         int64      `json:"active_alerts_1h"`
	LastEventAt            *time.Time `json:"last_event_at"`
}

ClusterMonitoringSummary represents one cluster in monitoring overview. ClusterMonitoringSummary 表示监控总览中的单个集群摘要。

type ClusterOverviewData

type ClusterOverviewData struct {
	GeneratedAt   time.Time                       `json:"generated_at"`
	Cluster       *ClusterBaseInfo                `json:"cluster"`
	Stats         *ClusterDetailStats             `json:"stats"`
	EventStats24h *EventStats                     `json:"event_stats_24h"`
	EventStats1h  *EventStats                     `json:"event_stats_1h"`
	MonitorConfig *monitor.MonitorConfig          `json:"monitor_config"`
	Nodes         []*NodeSnapshot                 `json:"nodes"`
	RecentEvents  []*monitor.ProcessEventWithHost `json:"recent_events"`
}

ClusterOverviewData represents one cluster monitoring detail payload. ClusterOverviewData 表示单集群监控详情数据。

type EventStats

type EventStats struct {
	Started             int64 `json:"started"`
	Stopped             int64 `json:"stopped"`
	Crashed             int64 `json:"crashed"`
	Restarted           int64 `json:"restarted"`
	RestartFailed       int64 `json:"restart_failed"`
	RestartLimitReached int64 `json:"restart_limit_reached"`
	NodeOffline         int64 `json:"node_offline"`
	NodeRecovered       int64 `json:"node_recovered"`
}

EventStats summarizes process events. EventStats 汇总进程事件统计。

func (*EventStats) CriticalCount

func (e *EventStats) CriticalCount() int64

CriticalCount returns the number of critical events. CriticalCount 返回关键告警事件数量。

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles monitoring overview HTTP requests. Handler 处理监控总览 HTTP 请求。

func NewHandler

func NewHandler(service *Service) *Handler

NewHandler creates a new monitoring handler. NewHandler 创建新的监控处理器。

func (*Handler) AcknowledgeAlert

func (h *Handler) AcknowledgeAlert(c *gin.Context)

AcknowledgeAlert handles POST /api/v1/monitoring/alerts/:eventId/ack AcknowledgeAlert 处理 POST /api/v1/monitoring/alerts/:eventId/ack

func (*Handler) AcknowledgeAlertInstance

func (h *Handler) AcknowledgeAlertInstance(c *gin.Context)

AcknowledgeAlertInstance handles POST /api/v1/monitoring/alert-instances/:id/ack. AcknowledgeAlertInstance 处理统一告警实例确认接口。

func (*Handler) AlertmanagerWebhook

func (h *Handler) AlertmanagerWebhook(c *gin.Context)

AlertmanagerWebhook handles POST /api/v1/monitoring/alertmanager/webhook. AlertmanagerWebhook 处理 Alertmanager webhook 告警推送。

func (*Handler) CloseAlertInstance

func (h *Handler) CloseAlertInstance(c *gin.Context)

CloseAlertInstance handles POST /api/v1/monitoring/alert-instances/:id/close. CloseAlertInstance 处理统一告警实例关闭接口。

func (*Handler) CreateAlertPolicy

func (h *Handler) CreateAlertPolicy(c *gin.Context)

CreateAlertPolicy handles POST /api/v1/monitoring/alert-policies. CreateAlertPolicy 处理统一告警策略创建接口。

func (*Handler) CreateNotificationChannel

func (h *Handler) CreateNotificationChannel(c *gin.Context)

CreateNotificationChannel handles POST /api/v1/monitoring/notification-channels CreateNotificationChannel 处理 POST /api/v1/monitoring/notification-channels

func (*Handler) CreateNotificationRoute

func (h *Handler) CreateNotificationRoute(c *gin.Context)

CreateNotificationRoute handles POST /api/v1/monitoring/notification-routes CreateNotificationRoute 处理新增通知路由接口。

func (*Handler) DeleteAlertPolicy

func (h *Handler) DeleteAlertPolicy(c *gin.Context)

DeleteAlertPolicy handles DELETE /api/v1/monitoring/alert-policies/:id. DeleteAlertPolicy 处理统一告警策略删除接口。

func (*Handler) DeleteNotificationChannel

func (h *Handler) DeleteNotificationChannel(c *gin.Context)

DeleteNotificationChannel handles DELETE /api/v1/monitoring/notification-channels/:id DeleteNotificationChannel 处理 DELETE /api/v1/monitoring/notification-channels/:id

func (*Handler) DeleteNotificationRoute

func (h *Handler) DeleteNotificationRoute(c *gin.Context)

DeleteNotificationRoute handles DELETE /api/v1/monitoring/notification-routes/:id DeleteNotificationRoute 处理删除通知路由接口。

func (*Handler) GetAlertPolicyCenterBootstrap

func (h *Handler) GetAlertPolicyCenterBootstrap(c *gin.Context)

GetAlertPolicyCenterBootstrap handles GET /api/v1/monitoring/alert-policies/bootstrap. GetAlertPolicyCenterBootstrap 处理统一策略中心初始化接口。

func (*Handler) GetClusterOverview

func (h *Handler) GetClusterOverview(c *gin.Context)

GetClusterOverview handles GET /api/v1/monitoring/clusters/:id/overview GetClusterOverview 处理 GET /api/v1/monitoring/clusters/:id/overview

func (*Handler) GetClustersHealth

func (h *Handler) GetClustersHealth(c *gin.Context)

GetClustersHealth handles GET /api/v1/clusters/health. GetClustersHealth 处理集群健康摘要查询接口。

func (*Handler) GetIntegrationStatus

func (h *Handler) GetIntegrationStatus(c *gin.Context)

GetIntegrationStatus handles GET /api/v1/monitoring/integration/status GetIntegrationStatus 处理 GET /api/v1/monitoring/integration/status

func (*Handler) GetOverview

func (h *Handler) GetOverview(c *gin.Context)

GetOverview handles GET /api/v1/monitoring/overview GetOverview 处理 GET /api/v1/monitoring/overview

func (*Handler) GetPlatformHealth

func (h *Handler) GetPlatformHealth(c *gin.Context)

GetPlatformHealth handles GET /api/v1/monitoring/platform-health. GetPlatformHealth 处理平台健康摘要查询接口。

func (*Handler) GetPrometheusDiscovery

func (h *Handler) GetPrometheusDiscovery(c *gin.Context)

GetPrometheusDiscovery handles GET /api/v1/monitoring/prometheus/discovery. GetPrometheusDiscovery 处理 Prometheus HTTP SD 接口。

func (*Handler) ListAlertInstances

func (h *Handler) ListAlertInstances(c *gin.Context)

ListAlertInstances handles GET /api/v1/monitoring/alert-instances. ListAlertInstances 处理统一告警实例列表查询接口。

func (*Handler) ListAlertPolicies

func (h *Handler) ListAlertPolicies(c *gin.Context)

ListAlertPolicies handles GET /api/v1/monitoring/alert-policies. ListAlertPolicies 处理统一告警策略列表接口。

func (*Handler) ListAlertPolicyExecutions

func (h *Handler) ListAlertPolicyExecutions(c *gin.Context)

ListAlertPolicyExecutions handles GET /api/v1/monitoring/alert-policies/:id/executions. ListAlertPolicyExecutions 处理统一告警策略执行历史列表接口。

func (*Handler) ListAlerts

func (h *Handler) ListAlerts(c *gin.Context)

ListAlerts handles GET /api/v1/monitoring/alerts ListAlerts 处理 GET /api/v1/monitoring/alerts

func (*Handler) ListClusterRules

func (h *Handler) ListClusterRules(c *gin.Context)

ListClusterRules handles GET /api/v1/monitoring/clusters/:id/rules ListClusterRules 处理 GET /api/v1/monitoring/clusters/:id/rules

func (*Handler) ListNotifiableUsers

func (h *Handler) ListNotifiableUsers(c *gin.Context)

ListNotifiableUsers handles GET /api/v1/monitoring/notifiable-users. ListNotifiableUsers 处理可通知用户列表接口。

func (*Handler) ListNotificationChannels

func (h *Handler) ListNotificationChannels(c *gin.Context)

ListNotificationChannels handles GET /api/v1/monitoring/notification-channels ListNotificationChannels 处理 GET /api/v1/monitoring/notification-channels

func (*Handler) ListNotificationDeliveries

func (h *Handler) ListNotificationDeliveries(c *gin.Context)

ListNotificationDeliveries handles GET /api/v1/monitoring/notification-deliveries ListNotificationDeliveries 处理通知投递历史列表接口。

func (*Handler) ListNotificationRoutes

func (h *Handler) ListNotificationRoutes(c *gin.Context)

ListNotificationRoutes handles GET /api/v1/monitoring/notification-routes ListNotificationRoutes 处理通知路由列表接口。

func (*Handler) ListRemoteAlerts

func (h *Handler) ListRemoteAlerts(c *gin.Context)

ListRemoteAlerts handles GET /api/v1/monitoring/remote-alerts. ListRemoteAlerts 处理远程告警记录查询接口。

func (*Handler) ProxyGrafana

func (h *Handler) ProxyGrafana(c *gin.Context)

ProxyGrafana handles reverse proxy for Grafana UI. ProxyGrafana 处理 Grafana UI 反向代理。

func (*Handler) SilenceAlert

func (h *Handler) SilenceAlert(c *gin.Context)

SilenceAlert handles POST /api/v1/monitoring/alerts/:eventId/silence SilenceAlert 处理 POST /api/v1/monitoring/alerts/:eventId/silence

func (*Handler) SilenceAlertInstance

func (h *Handler) SilenceAlertInstance(c *gin.Context)

SilenceAlertInstance handles POST /api/v1/monitoring/alert-instances/:id/silence. SilenceAlertInstance 处理统一告警实例静默接口。

func (*Handler) TestNotificationChannel

func (h *Handler) TestNotificationChannel(c *gin.Context)

TestNotificationChannel handles POST /api/v1/monitoring/notification-channels/:id/test TestNotificationChannel 处理通知渠道测试发送接口。

func (*Handler) TestNotificationChannelConnection

func (h *Handler) TestNotificationChannelConnection(c *gin.Context)

TestNotificationChannelConnection handles POST /api/v1/monitoring/notification-channels/test-connection TestNotificationChannelConnection 处理通知渠道连接测试接口。

func (*Handler) TestNotificationChannelDraft

func (h *Handler) TestNotificationChannelDraft(c *gin.Context)

TestNotificationChannelDraft handles POST /api/v1/monitoring/notification-channels/test TestNotificationChannelDraft 处理未保存通知渠道草稿测试发送接口。

func (*Handler) UpdateAlertPolicy

func (h *Handler) UpdateAlertPolicy(c *gin.Context)

UpdateAlertPolicy handles PUT /api/v1/monitoring/alert-policies/:id. UpdateAlertPolicy 处理统一告警策略更新接口。

func (*Handler) UpdateClusterRule

func (h *Handler) UpdateClusterRule(c *gin.Context)

UpdateClusterRule handles PUT /api/v1/monitoring/clusters/:id/rules/:ruleId UpdateClusterRule 处理 PUT /api/v1/monitoring/clusters/:id/rules/:ruleId

func (*Handler) UpdateNotificationChannel

func (h *Handler) UpdateNotificationChannel(c *gin.Context)

UpdateNotificationChannel handles PUT /api/v1/monitoring/notification-channels/:id UpdateNotificationChannel 处理 PUT /api/v1/monitoring/notification-channels/:id

func (*Handler) UpdateNotificationRoute

func (h *Handler) UpdateNotificationRoute(c *gin.Context)

UpdateNotificationRoute handles PUT /api/v1/monitoring/notification-routes/:id UpdateNotificationRoute 处理更新通知路由接口。

type IntegrationComponentStatus

type IntegrationComponentStatus struct {
	Name       string `json:"name"`
	URL        string `json:"url"`
	Healthy    bool   `json:"healthy"`
	StatusCode int    `json:"status_code"`
	Error      string `json:"error,omitempty"`
}

IntegrationComponentStatus represents one monitoring stack component status. IntegrationComponentStatus 表示监控栈组件状态。

type IntegrationStatusData

type IntegrationStatusData struct {
	GeneratedAt time.Time                     `json:"generated_at"`
	Components  []*IntegrationComponentStatus `json:"components"`
}

IntegrationStatusData represents full integration status payload. IntegrationStatusData 表示集成状态响应数据。

type NodeSnapshot

type NodeSnapshot struct {
	NodeID     uint   `json:"node_id"`
	HostID     uint   `json:"host_id"`
	HostName   string `json:"host_name"`
	HostIP     string `json:"host_ip"`
	Role       string `json:"role"`
	Status     string `json:"status"`
	IsOnline   bool   `json:"is_online"`
	ProcessPID int    `json:"process_pid"`
}

NodeSnapshot represents node runtime snapshot in monitoring detail. NodeSnapshot 表示监控详情中的节点运行快照。

type NotifiableUserListData

type NotifiableUserListData struct {
	GeneratedAt            time.Time                       `json:"generated_at"`
	Users                  []*NotificationRecipientUserDTO `json:"users"`
	DefaultReceiverUserIDs []uint64                        `json:"default_receiver_user_ids"`
}

NotifiableUserListData represents selectable notification recipient users. NotifiableUserListData 表示可选通知接收用户列表数据。

type NotificationChannel

type NotificationChannel struct {
	ID          uint                    `json:"id" gorm:"primaryKey;autoIncrement"`
	Name        string                  `json:"name" gorm:"size:120;not null;index"`
	Type        NotificationChannelType `json:"type" gorm:"size:30;not null;index"`
	Enabled     bool                    `json:"enabled"`
	Endpoint    string                  `json:"endpoint" gorm:"size:500"`
	Secret      string                  `json:"secret" gorm:"size:500"`
	ConfigJSON  string                  `json:"config_json" gorm:"type:text"`
	Description string                  `json:"description" gorm:"type:text"`
	CreatedAt   time.Time               `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt   time.Time               `json:"updated_at" gorm:"autoUpdateTime"`
}

NotificationChannel represents one alert notification channel. NotificationChannel 表示一条告警通知渠道配置。

func (NotificationChannel) TableName

func (NotificationChannel) TableName() string

TableName specifies the table name for NotificationChannel. TableName 指定 NotificationChannel 表名。

type NotificationChannelConfig

type NotificationChannelConfig struct {
	Email *NotificationChannelEmailConfig `json:"email,omitempty"`
}

NotificationChannelConfig represents channel-type-specific structured config. NotificationChannelConfig 表示按渠道类型区分的结构化配置。

type NotificationChannelConnectionTestResult

type NotificationChannelConnectionTestResult struct {
	Status    string     `json:"status"`
	CheckedAt *time.Time `json:"checked_at,omitempty"`
	LastError string     `json:"last_error,omitempty"`
}

NotificationChannelConnectionTestResult represents one SMTP connection test result. NotificationChannelConnectionTestResult 表示一次 SMTP 连接测试结果。

type NotificationChannelDTO

type NotificationChannelDTO struct {
	ID          uint                       `json:"id"`
	Name        string                     `json:"name"`
	Type        NotificationChannelType    `json:"type"`
	Enabled     bool                       `json:"enabled"`
	Endpoint    string                     `json:"endpoint"`
	Secret      string                     `json:"secret"`
	Config      *NotificationChannelConfig `json:"config,omitempty"`
	Description string                     `json:"description"`
	CreatedAt   time.Time                  `json:"created_at"`
	UpdatedAt   time.Time                  `json:"updated_at"`
}

NotificationChannelDTO is frontend DTO for notification channels. NotificationChannelDTO 是前端使用的通知渠道 DTO。

type NotificationChannelDraftTestRequest

type NotificationChannelDraftTestRequest struct {
	Channel        *UpsertNotificationChannelRequest `json:"channel"`
	ReceiverUserID uint64                            `json:"receiver_user_id"`
}

NotificationChannelDraftTestRequest represents manual test-send options for one unsaved notification channel draft. NotificationChannelDraftTestRequest 表示未保存通知渠道草稿的手动测试发送请求参数。

func (*NotificationChannelDraftTestRequest) Validate

Validate checks whether the draft test request contains a valid channel payload. Validate 校验草稿测试发送请求是否包含合法的渠道配置。

type NotificationChannelEmailConfig

type NotificationChannelEmailConfig struct {
	Protocol   string                    `json:"protocol"`
	Security   NotificationEmailSecurity `json:"security"`
	Host       string                    `json:"host"`
	Port       int                       `json:"port"`
	Username   string                    `json:"username,omitempty"`
	Password   string                    `json:"password,omitempty"`
	From       string                    `json:"from"`
	FromName   string                    `json:"from_name,omitempty"`
	Recipients []string                  `json:"recipients"`
}

NotificationChannelEmailConfig represents one SMTP-backed email channel config. NotificationChannelEmailConfig 表示一份基于 SMTP 的邮件渠道配置。

func (*NotificationChannelEmailConfig) Normalize

Normalize applies default values to email config. Normalize 为邮件配置补齐默认值。

func (*NotificationChannelEmailConfig) Validate

func (c *NotificationChannelEmailConfig) Validate() error

Validate validates email channel config values. Validate 校验邮件渠道配置参数。

type NotificationChannelListData

type NotificationChannelListData struct {
	GeneratedAt time.Time                 `json:"generated_at"`
	Total       int                       `json:"total"`
	Channels    []*NotificationChannelDTO `json:"channels"`
}

NotificationChannelListData represents channel list payload. NotificationChannelListData 表示通知渠道列表响应。

type NotificationChannelTestRequest

type NotificationChannelTestRequest struct {
	ReceiverUserID uint64 `json:"receiver_user_id"`
}

NotificationChannelTestRequest represents manual test-send options for one notification channel. NotificationChannelTestRequest 表示通知渠道手动测试发送的请求参数。

type NotificationChannelTestResult

type NotificationChannelTestResult struct {
	ChannelID    uint       `json:"channel_id"`
	DeliveryID   uint       `json:"delivery_id"`
	Status       string     `json:"status"`
	Receiver     string     `json:"receiver,omitempty"`
	SentAt       *time.Time `json:"sent_at,omitempty"`
	LastError    string     `json:"last_error,omitempty"`
	StatusCode   int        `json:"status_code,omitempty"`
	ResponseBody string     `json:"response_body,omitempty"`
}

NotificationChannelTestResult represents one test-send result for a channel. NotificationChannelTestResult 表示通知渠道一次测试发送结果。

type NotificationChannelType

type NotificationChannelType string

NotificationChannelType represents notification channel type. NotificationChannelType 表示通知渠道类型。

const (
	// NotificationChannelTypeWebhook indicates generic webhook.
	// NotificationChannelTypeWebhook 表示通用 Webhook。
	NotificationChannelTypeWebhook NotificationChannelType = "webhook"
	// NotificationChannelTypeEmail indicates email notification channel.
	// NotificationChannelTypeEmail 表示邮件通知渠道。
	NotificationChannelTypeEmail NotificationChannelType = "email"
	// NotificationChannelTypeWeCom indicates WeCom (企业微信) webhook channel.
	// NotificationChannelTypeWeCom 表示企业微信渠道。
	NotificationChannelTypeWeCom NotificationChannelType = "wecom"
	// NotificationChannelTypeDingTalk indicates DingTalk webhook channel.
	// NotificationChannelTypeDingTalk 表示钉钉渠道。
	NotificationChannelTypeDingTalk NotificationChannelType = "dingtalk"
	// NotificationChannelTypeFeishu indicates Feishu webhook channel.
	// NotificationChannelTypeFeishu 表示飞书渠道。
	NotificationChannelTypeFeishu NotificationChannelType = "feishu"
)

type NotificationDelivery

type NotificationDelivery struct {
	ID                  uint       `json:"id" gorm:"primaryKey;autoIncrement"`
	AlertID             string     `json:"alert_id" gorm:"size:255;index"`
	SourceType          string     `json:"source_type" gorm:"size:40;index"`
	SourceKey           string     `json:"source_key" gorm:"size:255;index;uniqueIndex:ux_monitoring_delivery_source_channel_event,priority:1"`
	PolicyID            uint       `json:"policy_id" gorm:"index"`
	ClusterID           string     `json:"cluster_id" gorm:"size:64;index"`
	ClusterName         string     `json:"cluster_name" gorm:"size:255;index"`
	AlertName           string     `json:"alert_name" gorm:"size:255;index"`
	ChannelID           uint       `json:"channel_id" gorm:"not null;index;uniqueIndex:ux_monitoring_delivery_source_channel_event,priority:2"`
	ChannelName         string     `json:"channel_name" gorm:"size:120"`
	EventType           string     `json:"event_type" gorm:"size:20;not null;index;uniqueIndex:ux_monitoring_delivery_source_channel_event,priority:3"`
	Status              string     `json:"status" gorm:"size:20;not null;index"`
	AttemptCount        int        `json:"attempt_count" gorm:"default:0"`
	LastError           string     `json:"last_error" gorm:"type:text"`
	RequestPayload      string     `json:"request_payload" gorm:"type:text"`
	ResponseStatusCode  int        `json:"response_status_code"`
	ResponseBodyExcerpt string     `json:"response_body_excerpt" gorm:"type:text"`
	SentAt              *time.Time `json:"sent_at"`
	CreatedAt           time.Time  `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt           time.Time  `json:"updated_at" gorm:"autoUpdateTime"`
}

NotificationDelivery represents one notification delivery record. NotificationDelivery 表示一条通知投递记录。

func (NotificationDelivery) TableName

func (NotificationDelivery) TableName() string

TableName specifies the table name for NotificationDelivery. TableName 指定 NotificationDelivery 表名。

type NotificationDeliveryDTO

type NotificationDeliveryDTO struct {
	ID                 uint       `json:"id"`
	AlertID            string     `json:"alert_id"`
	SourceType         string     `json:"source_type"`
	SourceKey          string     `json:"source_key"`
	PolicyID           uint       `json:"policy_id"`
	ClusterID          string     `json:"cluster_id,omitempty"`
	ClusterName        string     `json:"cluster_name,omitempty"`
	AlertName          string     `json:"alert_name,omitempty"`
	ChannelID          uint       `json:"channel_id"`
	ChannelName        string     `json:"channel_name,omitempty"`
	EventType          string     `json:"event_type"`
	Status             string     `json:"status"`
	AttemptCount       int        `json:"attempt_count"`
	LastError          string     `json:"last_error,omitempty"`
	ResponseStatusCode int        `json:"response_status_code,omitempty"`
	SentAt             *time.Time `json:"sent_at,omitempty"`
	CreatedAt          time.Time  `json:"created_at"`
	UpdatedAt          time.Time  `json:"updated_at"`
}

NotificationDeliveryDTO is frontend DTO for notification history entries. NotificationDeliveryDTO 是前端使用的通知历史 DTO。

type NotificationDeliveryEventType

type NotificationDeliveryEventType string

NotificationDeliveryEventType represents delivery lifecycle event type. NotificationDeliveryEventType 表示通知投递事件类型。

const (
	// NotificationDeliveryEventTypeFiring indicates a firing alert notification.
	// NotificationDeliveryEventTypeFiring 表示触发通知。
	NotificationDeliveryEventTypeFiring NotificationDeliveryEventType = "firing"
	// NotificationDeliveryEventTypeResolved indicates a resolved alert notification.
	// NotificationDeliveryEventTypeResolved 表示恢复通知。
	NotificationDeliveryEventTypeResolved NotificationDeliveryEventType = "resolved"
	// NotificationDeliveryEventTypeTest indicates a manual test notification.
	// NotificationDeliveryEventTypeTest 表示手动测试通知。
	NotificationDeliveryEventTypeTest NotificationDeliveryEventType = "test"
)

type NotificationDeliveryFilter

type NotificationDeliveryFilter struct {
	ChannelID uint                          `json:"channel_id"`
	PolicyID  uint                          `json:"policy_id"`
	Status    NotificationDeliveryStatus    `json:"status"`
	EventType NotificationDeliveryEventType `json:"event_type"`
	ClusterID string                        `json:"cluster_id"`
	StartTime *time.Time                    `json:"start_time"`
	EndTime   *time.Time                    `json:"end_time"`
	Page      int                           `json:"page"`
	PageSize  int                           `json:"page_size"`
}

NotificationDeliveryFilter represents notification history query filters. NotificationDeliveryFilter 表示通知历史查询过滤条件。

type NotificationDeliveryListData

type NotificationDeliveryListData struct {
	GeneratedAt time.Time                  `json:"generated_at"`
	Page        int                        `json:"page"`
	PageSize    int                        `json:"page_size"`
	Total       int64                      `json:"total"`
	Deliveries  []*NotificationDeliveryDTO `json:"deliveries"`
}

NotificationDeliveryListData represents notification history list payload. NotificationDeliveryListData 表示通知历史列表响应数据。

type NotificationDeliveryStatus

type NotificationDeliveryStatus string

NotificationDeliveryStatus represents current delivery execution state. NotificationDeliveryStatus 表示当前通知投递状态。

const (
	// NotificationDeliveryStatusPending indicates delivery is pending.
	// NotificationDeliveryStatusPending 表示投递待执行。
	NotificationDeliveryStatusPending NotificationDeliveryStatus = "pending"
	// NotificationDeliveryStatusSending indicates delivery is being sent.
	// NotificationDeliveryStatusSending 表示投递发送中。
	NotificationDeliveryStatusSending NotificationDeliveryStatus = "sending"
	// NotificationDeliveryStatusSent indicates delivery succeeded.
	// NotificationDeliveryStatusSent 表示投递成功。
	NotificationDeliveryStatusSent NotificationDeliveryStatus = "sent"
	// NotificationDeliveryStatusFailed indicates delivery failed.
	// NotificationDeliveryStatusFailed 表示投递失败。
	NotificationDeliveryStatusFailed NotificationDeliveryStatus = "failed"
	// NotificationDeliveryStatusRetrying indicates delivery is retrying.
	// NotificationDeliveryStatusRetrying 表示投递重试中。
	NotificationDeliveryStatusRetrying NotificationDeliveryStatus = "retrying"
	// NotificationDeliveryStatusCanceled indicates delivery is canceled.
	// NotificationDeliveryStatusCanceled 表示投递已取消。
	NotificationDeliveryStatusCanceled NotificationDeliveryStatus = "canceled"
)

type NotificationEmailSecurity

type NotificationEmailSecurity string

NotificationEmailSecurity represents SMTP transport security mode. NotificationEmailSecurity 表示 SMTP 传输安全模式。

const (
	// NotificationEmailSecurityNone indicates plain SMTP without TLS upgrade.
	// NotificationEmailSecurityNone 表示不使用 TLS 升级的明文 SMTP。
	NotificationEmailSecurityNone NotificationEmailSecurity = "none"
	// NotificationEmailSecurityStartTLS indicates STARTTLS upgrade after connect.
	// NotificationEmailSecurityStartTLS 表示连接后使用 STARTTLS 升级。
	NotificationEmailSecurityStartTLS NotificationEmailSecurity = "starttls"
	// NotificationEmailSecuritySSL indicates implicit TLS / SMTPS.
	// NotificationEmailSecuritySSL 表示隐式 TLS / SMTPS。
	NotificationEmailSecuritySSL NotificationEmailSecurity = "ssl"
)

type NotificationRecipientUserDTO

type NotificationRecipientUserDTO struct {
	ID       uint64 `json:"id"`
	Username string `json:"username"`
	Nickname string `json:"nickname"`
	Email    string `json:"email"`
	IsAdmin  bool   `json:"is_admin"`
}

NotificationRecipientUserDTO represents one selectable notification recipient user. NotificationRecipientUserDTO 表示一条可选通知接收用户记录。

type NotificationRoute

type NotificationRoute struct {
	ID                 uint      `json:"id" gorm:"primaryKey;autoIncrement"`
	Name               string    `json:"name" gorm:"size:120;not null;index"`
	Enabled            bool      `json:"enabled"`
	SourceType         string    `json:"source_type" gorm:"size:40;index"`
	ClusterID          string    `json:"cluster_id" gorm:"size:64;index"`
	Severity           string    `json:"severity" gorm:"size:20;index"`
	RuleKey            string    `json:"rule_key" gorm:"size:80;index"`
	ChannelID          uint      `json:"channel_id" gorm:"not null;index"`
	SendResolved       bool      `json:"send_resolved"`
	MuteIfAcknowledged bool      `json:"mute_if_acknowledged"`
	MuteIfSilenced     bool      `json:"mute_if_silenced"`
	CreatedAt          time.Time `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt          time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}

NotificationRoute represents one route from alert match condition to channel. NotificationRoute 表示一条从告警匹配条件到通知渠道的路由规则。

func (NotificationRoute) TableName

func (NotificationRoute) TableName() string

TableName specifies the table name for NotificationRoute. TableName 指定 NotificationRoute 表名。

type NotificationRouteDTO

type NotificationRouteDTO struct {
	ID                 uint      `json:"id"`
	Name               string    `json:"name"`
	Enabled            bool      `json:"enabled"`
	SourceType         string    `json:"source_type,omitempty"`
	ClusterID          string    `json:"cluster_id,omitempty"`
	Severity           string    `json:"severity,omitempty"`
	RuleKey            string    `json:"rule_key,omitempty"`
	ChannelID          uint      `json:"channel_id"`
	SendResolved       bool      `json:"send_resolved"`
	MuteIfAcknowledged bool      `json:"mute_if_acknowledged"`
	MuteIfSilenced     bool      `json:"mute_if_silenced"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

NotificationRouteDTO is frontend DTO for notification routes. NotificationRouteDTO 是前端使用的通知路由 DTO。

type NotificationRouteListData

type NotificationRouteListData struct {
	GeneratedAt time.Time               `json:"generated_at"`
	Total       int                     `json:"total"`
	Routes      []*NotificationRouteDTO `json:"routes"`
}

NotificationRouteListData represents notification route list payload. NotificationRouteListData 表示通知路由列表响应。

type OverviewData

type OverviewData struct {
	GeneratedAt   time.Time                   `json:"generated_at"`
	Stats         *OverviewStats              `json:"stats"`
	EventStats24h *EventStats                 `json:"event_stats_24h"`
	Clusters      []*ClusterMonitoringSummary `json:"clusters"`
}

OverviewData represents the monitoring overview payload. OverviewData 表示监控总览数据。

type OverviewStats

type OverviewStats struct {
	TotalClusters     int   `json:"total_clusters"`
	HealthyClusters   int   `json:"healthy_clusters"`
	UnhealthyClusters int   `json:"unhealthy_clusters"`
	UnknownClusters   int   `json:"unknown_clusters"`
	TotalNodes        int   `json:"total_nodes"`
	OnlineNodes       int   `json:"online_nodes"`
	OfflineNodes      int   `json:"offline_nodes"`
	CrashedEvents24h  int64 `json:"crashed_events_24h"`
	RestartFailed24h  int64 `json:"restart_failed_events_24h"`
	ActiveAlerts1h    int64 `json:"active_alerts_1h"`
}

OverviewStats represents global monitoring statistics. OverviewStats 表示全局监控统计。

type PlatformHealthData

type PlatformHealthData struct {
	GeneratedAt       time.Time `json:"generated_at"`
	HealthStatus      string    `json:"health_status"`
	TotalClusters     int       `json:"total_clusters"`
	HealthyClusters   int       `json:"healthy_clusters"`
	DegradedClusters  int       `json:"degraded_clusters"`
	UnhealthyClusters int       `json:"unhealthy_clusters"`
	UnknownClusters   int       `json:"unknown_clusters"`
	ActiveAlerts      int64     `json:"active_alerts"`
	CriticalAlerts    int64     `json:"critical_alerts"`
}

PlatformHealthData represents platform-level health summary. PlatformHealthData 表示平台级健康汇总。

type PrometheusSDTargetGroup

type PrometheusSDTargetGroup struct {
	Targets []string          `json:"targets"`
	Labels  map[string]string `json:"labels,omitempty"`
}

PrometheusSDTargetGroup is one target group in Prometheus HTTP SD response. PrometheusSDTargetGroup 是 Prometheus HTTP SD 响应中的目标组。

type RemoteAlertClusterStat

type RemoteAlertClusterStat struct {
	ClusterID     string `json:"cluster_id"`
	ActiveCount   int64  `json:"active_count"`
	CriticalCount int64  `json:"critical_count"`
}

RemoteAlertClusterStat represents aggregated remote alert counters per cluster. RemoteAlertClusterStat 表示按集群聚合的远程告警计数。

type RemoteAlertFilter

type RemoteAlertFilter struct {
	ClusterID string     `json:"cluster_id"`
	Status    string     `json:"status"`
	StartTime *time.Time `json:"start_time"`
	EndTime   *time.Time `json:"end_time"`
	Page      int        `json:"page"`
	PageSize  int        `json:"page_size"`
}

RemoteAlertFilter represents query filters for remote alert records. RemoteAlertFilter 表示远程告警记录查询过滤条件。

type RemoteAlertItem

type RemoteAlertItem struct {
	ID             uint       `json:"id"`
	Fingerprint    string     `json:"fingerprint"`
	Status         string     `json:"status"`
	Receiver       string     `json:"receiver"`
	AlertName      string     `json:"alert_name"`
	Severity       string     `json:"severity"`
	ClusterID      string     `json:"cluster_id"`
	ClusterName    string     `json:"cluster_name"`
	Env            string     `json:"env"`
	Summary        string     `json:"summary"`
	Description    string     `json:"description"`
	StartsAt       int64      `json:"starts_at"`
	EndsAt         int64      `json:"ends_at"`
	ResolvedAt     *time.Time `json:"resolved_at"`
	LastReceivedAt time.Time  `json:"last_received_at"`
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
}

RemoteAlertItem represents one remote alert record returned to frontend. RemoteAlertItem 表示返回给前端的单条远程告警记录。

type RemoteAlertListData

type RemoteAlertListData struct {
	GeneratedAt time.Time          `json:"generated_at"`
	Page        int                `json:"page"`
	PageSize    int                `json:"page_size"`
	Total       int64              `json:"total"`
	Alerts      []*RemoteAlertItem `json:"alerts"`
}

RemoteAlertListData represents remote alert list response payload. RemoteAlertListData 表示远程告警列表响应数据。

type RemoteAlertRecord

type RemoteAlertRecord struct {
	ID uint `json:"id" gorm:"primaryKey;autoIncrement"`

	Fingerprint string `json:"fingerprint" gorm:"size:255;not null;index;uniqueIndex:ux_monitoring_remote_alert"`
	StartsAt    int64  `json:"starts_at" gorm:"not null;index;uniqueIndex:ux_monitoring_remote_alert"`

	Status      string `json:"status" gorm:"size:32;index"`
	Receiver    string `json:"receiver" gorm:"size:200"`
	AlertName   string `json:"alert_name" gorm:"size:255;index"`
	Severity    string `json:"severity" gorm:"size:64;index"`
	ClusterID   string `json:"cluster_id" gorm:"size:64;index"`
	ClusterName string `json:"cluster_name" gorm:"size:255;index"`
	Env         string `json:"env" gorm:"size:64;index"`

	GeneratorURL string `json:"generator_url" gorm:"size:1024"`
	Summary      string `json:"summary" gorm:"type:text"`
	Description  string `json:"description" gorm:"type:text"`

	LabelsJSON      string `json:"labels_json" gorm:"type:text"`
	AnnotationsJSON string `json:"annotations_json" gorm:"type:text"`

	EndsAt         int64      `json:"ends_at"`
	ResolvedAt     *time.Time `json:"resolved_at"`
	LastReceivedAt time.Time  `json:"last_received_at" gorm:"index"`
	CreatedAt      time.Time  `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt      time.Time  `json:"updated_at" gorm:"autoUpdateTime"`
}

RemoteAlertRecord stores one Alertmanager webhook alert after normalization. RemoteAlertRecord 保存标准化后的 Alertmanager webhook 告警记录。

func (RemoteAlertRecord) TableName

func (RemoteAlertRecord) TableName() string

TableName specifies table name for RemoteAlertRecord. TableName 指定 RemoteAlertRecord 表名。

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository provides data access for monitoring center. Repository 提供监控中心的数据访问能力。

func NewRepository

func NewRepository(db *gorm.DB) *Repository

NewRepository creates a new monitoring repository. NewRepository 创建监控中心仓库。

func (*Repository) ApplyAlertPolicyExecutionState

func (r *Repository) ApplyAlertPolicyExecutionState(ctx context.Context, policyID uint, state *AlertPolicyExecutionStateUpdate) error

ApplyAlertPolicyExecutionState updates execution aggregate fields for one policy. ApplyAlertPolicyExecutionState 更新单条策略的执行聚合字段。

func (*Repository) CreateAlertPolicy

func (r *Repository) CreateAlertPolicy(ctx context.Context, policy *AlertPolicy) error

CreateAlertPolicy creates one alert policy resource. CreateAlertPolicy 创建统一告警策略资源。

func (*Repository) CreateNotificationChannel

func (r *Repository) CreateNotificationChannel(ctx context.Context, channel *NotificationChannel) error

CreateNotificationChannel creates a channel. CreateNotificationChannel 创建通知渠道。

func (*Repository) CreateNotificationDelivery

func (r *Repository) CreateNotificationDelivery(ctx context.Context, delivery *NotificationDelivery) error

CreateNotificationDelivery creates one delivery record. CreateNotificationDelivery 创建一条通知投递记录。

func (*Repository) CreateNotificationRoute

func (r *Repository) CreateNotificationRoute(ctx context.Context, route *NotificationRoute) error

CreateNotificationRoute creates one notification route. CreateNotificationRoute 创建一条通知路由。

func (*Repository) CreateRule

func (r *Repository) CreateRule(ctx context.Context, rule *AlertRule) error

CreateRule creates one alert rule. CreateRule 创建告警规则。

func (*Repository) DeleteAlertPolicy

func (r *Repository) DeleteAlertPolicy(ctx context.Context, id uint) error

DeleteAlertPolicy deletes one alert policy resource by ID. DeleteAlertPolicy 根据 ID 删除统一告警策略资源。

func (*Repository) DeleteNotificationChannel

func (r *Repository) DeleteNotificationChannel(ctx context.Context, id uint) error

DeleteNotificationChannel deletes channel by ID. DeleteNotificationChannel 根据 ID 删除通知渠道。

func (*Repository) DeleteNotificationRoute

func (r *Repository) DeleteNotificationRoute(ctx context.Context, id uint) error

DeleteNotificationRoute deletes one notification route by ID. DeleteNotificationRoute 根据 ID 删除一条通知路由。

func (*Repository) GetAlertPolicyByClusterAndLegacyRuleKey

func (r *Repository) GetAlertPolicyByClusterAndLegacyRuleKey(ctx context.Context, clusterID string, legacyRuleKey string) (*AlertPolicy, error)

GetAlertPolicyByClusterAndLegacyRuleKey returns one alert policy by cluster scope and legacy rule key. GetAlertPolicyByClusterAndLegacyRuleKey 根据集群范围和旧规则键返回统一告警策略。

func (*Repository) GetAlertPolicyByID

func (r *Repository) GetAlertPolicyByID(ctx context.Context, id uint) (*AlertPolicy, error)

GetAlertPolicyByID returns one alert policy by ID. GetAlertPolicyByID 根据 ID 返回统一告警策略。

func (*Repository) GetAlertStateBySourceKey

func (r *Repository) GetAlertStateBySourceKey(ctx context.Context, sourceKey string) (*AlertState, error)

GetAlertStateBySourceKey returns one unified alert state by source key. GetAlertStateBySourceKey 根据 source key 返回统一告警状态。

func (*Repository) GetEventStateByEventID

func (r *Repository) GetEventStateByEventID(ctx context.Context, eventID uint) (*AlertEventState, error)

GetEventStateByEventID returns state for one event. Nil if not found. GetEventStateByEventID 返回单个事件状态,未找到返回 nil。

func (*Repository) GetNotificationChannelByID

func (r *Repository) GetNotificationChannelByID(ctx context.Context, id uint) (*NotificationChannel, error)

GetNotificationChannelByID returns one channel by ID. GetNotificationChannelByID 根据 ID 返回单条通知渠道。

func (*Repository) GetNotificationDeliveryByDedupKey

func (r *Repository) GetNotificationDeliveryByDedupKey(ctx context.Context, sourceKey string, channelID uint, eventType string) (*NotificationDelivery, error)

GetNotificationDeliveryByDedupKey returns one delivery record by source_key/channel/event tuple. GetNotificationDeliveryByDedupKey 根据 source_key/channel/event 三元组返回单条投递记录。

func (*Repository) GetNotificationRouteByID

func (r *Repository) GetNotificationRouteByID(ctx context.Context, id uint) (*NotificationRoute, error)

GetNotificationRouteByID returns one notification route by ID. GetNotificationRouteByID 根据 ID 返回单条通知路由。

func (*Repository) GetRemoteAlertByFingerprintAndStartsAt

func (r *Repository) GetRemoteAlertByFingerprintAndStartsAt(ctx context.Context, fingerprint string, startsAt int64) (*RemoteAlertRecord, error)

GetRemoteAlertByFingerprintAndStartsAt returns one remote alert record by unique key. GetRemoteAlertByFingerprintAndStartsAt 根据唯一键返回一条远程告警记录。

func (*Repository) GetRemoteAlertClusterStats

func (r *Repository) GetRemoteAlertClusterStats(ctx context.Context, clusterIDs []string) (map[string]*RemoteAlertClusterStat, error)

GetRemoteAlertClusterStats returns active/critical remote alert counters grouped by cluster_id. GetRemoteAlertClusterStats 返回按 cluster_id 聚合的远程告警活动/严重数。

func (*Repository) GetRuleByClusterAndKey

func (r *Repository) GetRuleByClusterAndKey(ctx context.Context, clusterID uint, ruleKey string) (*AlertRule, error)

GetRuleByClusterAndKey gets one rule by cluster and rule key. GetRuleByClusterAndKey 根据集群和规则键获取规则。

func (*Repository) GetRuleByID

func (r *Repository) GetRuleByID(ctx context.Context, id uint) (*AlertRule, error)

GetRuleByID gets one alert rule by ID. GetRuleByID 根据 ID 获取单条告警规则。

func (*Repository) ListAlertPolicies

func (r *Repository) ListAlertPolicies(ctx context.Context) ([]*AlertPolicy, error)

ListAlertPolicies returns all unified alert policies. ListAlertPolicies 返回全部统一告警策略。

func (*Repository) ListAlertStatesBySourceKeys

func (r *Repository) ListAlertStatesBySourceKeys(ctx context.Context, sourceKeys []string) (map[string]*AlertState, error)

ListAlertStatesBySourceKeys returns unified alert states mapped by source_key. ListAlertStatesBySourceKeys 根据 source_key 列表返回统一告警状态映射。

func (*Repository) ListCriticalEvents

func (r *Repository) ListCriticalEvents(ctx context.Context, filter *AlertEventQueryFilter) ([]*AlertEventSource, int64, error)

ListCriticalEvents returns critical process events joined with host and cluster info. ListCriticalEvents 返回关键进程事件(含主机和集群信息)。

func (*Repository) ListEnabledAlertPoliciesByClusterAndLegacyRuleKey

func (r *Repository) ListEnabledAlertPoliciesByClusterAndLegacyRuleKey(ctx context.Context, clusterID string, legacyRuleKey string) ([]*AlertPolicy, error)

ListEnabledAlertPoliciesByClusterAndLegacyRuleKey returns enabled policies for one cluster/rule pair. ListEnabledAlertPoliciesByClusterAndLegacyRuleKey 返回指定集群和旧规则键下已启用的统一策略。

func (*Repository) ListEnabledManagedMetricAlertPolicies

func (r *Repository) ListEnabledManagedMetricAlertPolicies(ctx context.Context) ([]*AlertPolicy, error)

func (*Repository) ListEventStatesByEventIDs

func (r *Repository) ListEventStatesByEventIDs(ctx context.Context, eventIDs []uint) (map[uint]*AlertEventState, error)

ListEventStatesByEventIDs returns states mapped by event_id. ListEventStatesByEventIDs 根据事件 ID 列表返回状态映射。

func (*Repository) ListNotifiableUsers

func (r *Repository) ListNotifiableUsers(ctx context.Context) ([]*auth.User, error)

ListNotifiableUsers returns active users with configured email addresses. ListNotifiableUsers 返回已启用且配置了邮箱的可通知用户。

func (*Repository) ListNotificationChannels

func (r *Repository) ListNotificationChannels(ctx context.Context) ([]*NotificationChannel, error)

ListNotificationChannels returns all notification channels. ListNotificationChannels 返回全部通知渠道。

func (*Repository) ListNotificationDeliveries

func (r *Repository) ListNotificationDeliveries(ctx context.Context, filter *NotificationDeliveryFilter) ([]*NotificationDelivery, int64, error)

ListNotificationDeliveries returns notification delivery records with pagination and filters. ListNotificationDeliveries 返回通知投递记录列表(支持分页和过滤)。

func (*Repository) ListNotificationRoutes

func (r *Repository) ListNotificationRoutes(ctx context.Context) ([]*NotificationRoute, error)

ListNotificationRoutes returns all notification routes. ListNotificationRoutes 返回全部通知路由。

func (*Repository) ListRemoteAlerts

func (r *Repository) ListRemoteAlerts(ctx context.Context, filter *RemoteAlertFilter) ([]*RemoteAlertRecord, int64, error)

ListRemoteAlerts returns remote alert records with pagination and filters. ListRemoteAlerts 返回远程告警记录列表(支持分页与过滤)。

func (*Repository) ListRulesByClusterID

func (r *Repository) ListRulesByClusterID(ctx context.Context, clusterID uint) ([]*AlertRule, error)

ListRulesByClusterID returns alert rules for one cluster. ListRulesByClusterID 返回指定集群的告警规则。

func (*Repository) ListUsersByIDs

func (r *Repository) ListUsersByIDs(ctx context.Context, userIDs []uint64) ([]*auth.User, error)

ListUsersByIDs returns users by IDs without filtering status or email. ListUsersByIDs 根据 ID 列表返回用户,不额外过滤状态或邮箱。

func (*Repository) SaveAlertPolicy

func (r *Repository) SaveAlertPolicy(ctx context.Context, policy *AlertPolicy) error

SaveAlertPolicy updates one alert policy resource. SaveAlertPolicy 更新统一告警策略资源。

func (*Repository) SaveAlertState

func (r *Repository) SaveAlertState(ctx context.Context, state *AlertState) error

SaveAlertState creates or updates one unified alert state. SaveAlertState 创建或更新一条统一告警状态。

func (*Repository) SaveEventState

func (r *Repository) SaveEventState(ctx context.Context, state *AlertEventState) error

SaveEventState creates or updates alert event state. SaveEventState 创建或更新告警事件状态。

func (*Repository) SaveNotificationChannel

func (r *Repository) SaveNotificationChannel(ctx context.Context, channel *NotificationChannel) error

SaveNotificationChannel updates a channel. SaveNotificationChannel 更新通知渠道。

func (*Repository) SaveNotificationDelivery

func (r *Repository) SaveNotificationDelivery(ctx context.Context, delivery *NotificationDelivery) error

SaveNotificationDelivery updates one delivery record. SaveNotificationDelivery 更新一条通知投递记录。

func (*Repository) SaveNotificationRoute

func (r *Repository) SaveNotificationRoute(ctx context.Context, route *NotificationRoute) error

SaveNotificationRoute updates one notification route. SaveNotificationRoute 更新一条通知路由。

func (*Repository) SaveRule

func (r *Repository) SaveRule(ctx context.Context, rule *AlertRule) error

SaveRule updates one alert rule. SaveRule 更新告警规则。

func (*Repository) UpsertRemoteAlert

func (r *Repository) UpsertRemoteAlert(ctx context.Context, record *RemoteAlertRecord) error

UpsertRemoteAlert creates or updates one normalized remote alert record. UpsertRemoteAlert 创建或更新一条标准化远程告警记录。

type Response

type Response struct {
	ErrorMsg string      `json:"error_msg"`
	Data     interface{} `json:"data"`
}

Response is the standard API response for monitoring endpoints. Response 是监控接口的标准响应结构。

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides monitoring center data for UI. Service 为 UI 提供监控中心数据。

func NewService

func NewService(clusterService *cluster.Service, monitorService *monitor.Service, repo *Repository) *Service

NewService creates a monitoring service. NewService 创建监控中心服务。

func (*Service) AcknowledgeAlert

func (s *Service) AcknowledgeAlert(ctx context.Context, eventID uint, operator, note string) (*AlertActionResult, error)

AcknowledgeAlert marks one alert event as acknowledged. AcknowledgeAlert 将单条告警标记为已确认。

func (*Service) AcknowledgeAlertInstance

func (s *Service) AcknowledgeAlertInstance(ctx context.Context, alertID, operator, note string) (*AlertInstanceActionResult, error)

AcknowledgeAlertInstance acknowledges one unified alert instance. AcknowledgeAlertInstance 确认一条统一告警实例。

func (*Service) BuildPrometheusSDTargets

func (s *Service) BuildPrometheusSDTargets(ctx context.Context) ([]*PrometheusSDTargetGroup, error)

BuildPrometheusSDTargets builds Prometheus HTTP SD target groups from managed clusters. BuildPrometheusSDTargets 从受管集群构建 Prometheus HTTP SD 目标组。

func (*Service) CloseAlertInstance

func (s *Service) CloseAlertInstance(ctx context.Context, alertID, operator, note string) (*AlertInstanceActionResult, error)

CloseAlertInstance manually closes one alert incident and suppresses follow-up notifications for the same incident. CloseAlertInstance 人工关闭一条告警事件,并抑制该事件后续通知。

func (*Service) CreateAlertPolicy

func (s *Service) CreateAlertPolicy(ctx context.Context, req *UpsertAlertPolicyRequest) (*AlertPolicyDTO, error)

CreateAlertPolicy creates one unified alert policy resource. CreateAlertPolicy 创建统一告警策略资源。

func (*Service) CreateNotificationChannel

func (s *Service) CreateNotificationChannel(ctx context.Context, req *UpsertNotificationChannelRequest) (*NotificationChannelDTO, error)

CreateNotificationChannel creates one notification channel. CreateNotificationChannel 创建一条通知渠道。

func (*Service) CreateNotificationRoute

func (s *Service) CreateNotificationRoute(ctx context.Context, req *UpsertNotificationRouteRequest) (*NotificationRouteDTO, error)

CreateNotificationRoute creates one notification route. CreateNotificationRoute 创建一条通知路由。

func (*Service) DeleteAlertPolicy

func (s *Service) DeleteAlertPolicy(ctx context.Context, id uint) error

DeleteAlertPolicy deletes one unified alert policy resource. DeleteAlertPolicy 删除统一告警策略资源。

func (*Service) DeleteNotificationChannel

func (s *Service) DeleteNotificationChannel(ctx context.Context, id uint) error

DeleteNotificationChannel deletes one notification channel. DeleteNotificationChannel 删除一条通知渠道。

func (*Service) DeleteNotificationRoute

func (s *Service) DeleteNotificationRoute(ctx context.Context, id uint) error

DeleteNotificationRoute deletes one notification route. DeleteNotificationRoute 删除一条通知路由。

func (*Service) DispatchActiveNodeOfflineReminder

func (s *Service) DispatchActiveNodeOfflineReminder(
	ctx context.Context,
	clusterID uint,
	clusterName string,
	nodeID uint,
) error

func (*Service) DispatchAlertPolicyEvent

func (s *Service) DispatchAlertPolicyEvent(ctx context.Context, event *monitor.ProcessEvent) error

DispatchAlertPolicyEvent evaluates one process event against unified alert policies. DispatchAlertPolicyEvent 根据统一告警策略执行一次进程事件评估。

func (*Service) EvaluateNodeHealthAlerts

func (s *Service) EvaluateNodeHealthAlerts(ctx context.Context) error

EvaluateNodeHealthAlerts scans managed clusters and emits node_offline / node_recovered events when one node crosses the sustained-health boundary. EvaluateNodeHealthAlerts 扫描受管集群,并在节点跨越持续状态边界时发出 node_offline / node_recovered 事件。

func (*Service) GetAlertPolicyCenterBootstrap

func (s *Service) GetAlertPolicyCenterBootstrap(ctx context.Context) (*AlertPolicyCenterBootstrapData, error)

GetAlertPolicyCenterBootstrap returns unified policy-center bootstrap payload. GetAlertPolicyCenterBootstrap 返回统一策略中心初始化数据。

func (*Service) GetClusterOverview

func (s *Service) GetClusterOverview(ctx context.Context, clusterID uint) (*ClusterOverviewData, error)

GetClusterOverview returns monitoring detail data for one cluster. GetClusterOverview 返回单集群监控详情数据。

func (*Service) GetClustersHealth

func (s *Service) GetClustersHealth(ctx context.Context) (*ClusterHealthData, error)

GetClustersHealth returns cluster-level health summary for monitoring center. GetClustersHealth 返回监控中心集群级健康摘要。

func (*Service) GetIntegrationStatus

func (s *Service) GetIntegrationStatus(ctx context.Context) (*IntegrationStatusData, error)

GetIntegrationStatus returns integration health status of monitoring stack. GetIntegrationStatus 返回监控栈集成状态。

func (*Service) GetOverview

func (s *Service) GetOverview(ctx context.Context) (*OverviewData, error)

GetOverview returns global monitoring overview data. GetOverview 返回全局监控总览数据。

func (*Service) GetPlatformHealth

func (s *Service) GetPlatformHealth(ctx context.Context) (*PlatformHealthData, error)

GetPlatformHealth returns platform-level health summary. GetPlatformHealth 返回平台级健康摘要。

func (*Service) HandleAlertmanagerWebhook

func (s *Service) HandleAlertmanagerWebhook(ctx context.Context, payload *AlertmanagerWebhookPayload) (*AlertmanagerWebhookResult, error)

HandleAlertmanagerWebhook ingests one Alertmanager webhook payload into persistent records. HandleAlertmanagerWebhook 将 Alertmanager webhook 请求写入持久化告警记录。

func (*Service) ListAlertInstances

func (s *Service) ListAlertInstances(ctx context.Context, filter *AlertInstanceFilter) (*AlertInstanceListData, error)

ListAlertInstances returns unified alert instances merged from local and remote sources. ListAlertInstances 返回本地与远程来源合并后的统一告警实例列表。

func (*Service) ListAlertPolicies

func (s *Service) ListAlertPolicies(ctx context.Context) (*AlertPolicyListData, error)

ListAlertPolicies returns unified alert policy resources. ListAlertPolicies 返回统一告警策略资源列表。

func (*Service) ListAlertPolicyExecutions

func (s *Service) ListAlertPolicyExecutions(ctx context.Context, policyID uint, filter *NotificationDeliveryFilter) (*NotificationDeliveryListData, error)

ListAlertPolicyExecutions returns notification execution history for one unified alert policy. ListAlertPolicyExecutions 返回单条统一告警策略的通知执行历史。

func (*Service) ListAlerts

func (s *Service) ListAlerts(ctx context.Context, filter *AlertFilter) (*AlertListData, error)

ListAlerts returns alert center data. ListAlerts 返回告警中心数据。

func (*Service) ListClusterRules

func (s *Service) ListClusterRules(ctx context.Context, clusterID uint) (*AlertRuleListData, error)

ListClusterRules returns rules for one cluster. ListClusterRules 返回单集群告警规则列表。

func (*Service) ListNotifiableUsers

func (s *Service) ListNotifiableUsers(ctx context.Context) (*NotifiableUserListData, error)

ListNotifiableUsers returns notification recipient directory data. ListNotifiableUsers 返回通知接收用户目录数据。

func (*Service) ListNotificationChannels

func (s *Service) ListNotificationChannels(ctx context.Context) (*NotificationChannelListData, error)

ListNotificationChannels returns all notification channels. ListNotificationChannels 返回全部通知渠道。

func (*Service) ListNotificationDeliveries

func (s *Service) ListNotificationDeliveries(ctx context.Context, filter *NotificationDeliveryFilter) (*NotificationDeliveryListData, error)

ListNotificationDeliveries returns notification delivery history. ListNotificationDeliveries 返回通知投递历史。

func (*Service) ListNotificationRoutes

func (s *Service) ListNotificationRoutes(ctx context.Context) (*NotificationRouteListData, error)

ListNotificationRoutes returns all notification routes. ListNotificationRoutes 返回全部通知路由。

func (*Service) ListRemoteAlerts

func (s *Service) ListRemoteAlerts(ctx context.Context, filter *RemoteAlertFilter) (*RemoteAlertListData, error)

ListRemoteAlerts returns remote alert records with paging filters. ListRemoteAlerts 返回远程告警记录(支持分页过滤)。

func (*Service) SilenceAlert

func (s *Service) SilenceAlert(ctx context.Context, eventID uint, operator string, durationMinutes int, note string) (*AlertActionResult, error)

SilenceAlert silences one alert event for a duration in minutes. SilenceAlert 将单条告警静默一段分钟数。

func (*Service) SilenceAlertInstance

func (s *Service) SilenceAlertInstance(ctx context.Context, alertID, operator string, durationMinutes int, note string) (*AlertInstanceActionResult, error)

SilenceAlertInstance silences one unified alert instance for a duration in minutes. SilenceAlertInstance 将一条统一告警实例静默指定分钟数。

func (*Service) StartNodeHealthEvaluator

func (s *Service) StartNodeHealthEvaluator(ctx context.Context)

StartNodeHealthEvaluator starts a background loop that converts sustained node-unavailable states into local alertable events. StartNodeHealthEvaluator 启动后台循环,将持续性的节点不可用状态转换为本地可告警事件。

func (*Service) SyncManagedAlertingArtifacts

func (s *Service) SyncManagedAlertingArtifacts(ctx context.Context) error

SyncManagedAlertingArtifacts keeps local Prometheus/Alertmanager demo runtime in sync with unified metric policies. SyncManagedAlertingArtifacts 将统一指标策略同步到本地 Prometheus / Alertmanager demo 运行时。

func (*Service) TestNotificationChannel

func (s *Service) TestNotificationChannel(ctx context.Context, id uint, req *NotificationChannelTestRequest) (*NotificationChannelTestResult, error)

TestNotificationChannel performs one test send against a notification channel. TestNotificationChannel 对指定通知渠道执行一次测试发送。

func (*Service) TestNotificationChannelConnection

func (s *Service) TestNotificationChannelConnection(ctx context.Context, req *UpsertNotificationChannelRequest) (*NotificationChannelConnectionTestResult, error)

TestNotificationChannelConnection validates and probes one draft notification channel connection. TestNotificationChannelConnection 校验并测试一份通知渠道草稿配置的连接可用性。

func (*Service) TestNotificationChannelDraft

func (s *Service) TestNotificationChannelDraft(ctx context.Context, req *NotificationChannelDraftTestRequest) (*NotificationChannelTestResult, error)

TestNotificationChannelDraft performs one test send against an unsaved notification channel draft. TestNotificationChannelDraft 对未保存的通知渠道草稿执行一次测试发送。

func (*Service) UpdateAlertPolicy

func (s *Service) UpdateAlertPolicy(ctx context.Context, id uint, req *UpsertAlertPolicyRequest) (*AlertPolicyDTO, error)

UpdateAlertPolicy updates one unified alert policy resource. UpdateAlertPolicy 更新统一告警策略资源。

func (*Service) UpdateClusterRule

func (s *Service) UpdateClusterRule(ctx context.Context, clusterID, ruleID uint, req *UpdateAlertRuleRequest) (*AlertRuleDTO, error)

UpdateClusterRule updates one rule in cluster scope. UpdateClusterRule 更新集群维度的一条告警规则。

func (*Service) UpdateNotificationChannel

func (s *Service) UpdateNotificationChannel(ctx context.Context, id uint, req *UpsertNotificationChannelRequest) (*NotificationChannelDTO, error)

UpdateNotificationChannel updates one notification channel. UpdateNotificationChannel 更新一条通知渠道。

func (*Service) UpdateNotificationRoute

func (s *Service) UpdateNotificationRoute(ctx context.Context, id uint, req *UpsertNotificationRouteRequest) (*NotificationRouteDTO, error)

UpdateNotificationRoute updates one notification route. UpdateNotificationRoute 更新一条通知路由。

type SilenceAlertRequest

type SilenceAlertRequest struct {
	DurationMinutes int    `json:"duration_minutes"`
	Note            string `json:"note"`
}

SilenceAlertRequest represents silence action payload. SilenceAlertRequest 表示静默告警请求。

func (*SilenceAlertRequest) Validate

func (r *SilenceAlertRequest) Validate() error

Validate validates silence request. Validate 验证静默请求参数。

type UpdateAlertRuleRequest

type UpdateAlertRuleRequest struct {
	RuleName      *string        `json:"rule_name"`
	Description   *string        `json:"description"`
	Severity      *AlertSeverity `json:"severity"`
	Enabled       *bool          `json:"enabled"`
	Threshold     *int           `json:"threshold"`
	WindowSeconds *int           `json:"window_seconds"`
}

UpdateAlertRuleRequest represents patch fields for one alert rule. UpdateAlertRuleRequest 表示告警规则更新请求。

func (*UpdateAlertRuleRequest) Validate

func (r *UpdateAlertRuleRequest) Validate() error

Validate validates update request values. Validate 验证规则更新请求参数。

type UpsertAlertPolicyRequest

type UpsertAlertPolicyRequest struct {
	Name                   string                     `json:"name"`
	Description            string                     `json:"description"`
	PolicyType             AlertPolicyBuilderKind     `json:"policy_type"`
	TemplateKey            string                     `json:"template_key"`
	LegacyRuleKey          string                     `json:"legacy_rule_key"`
	ClusterID              string                     `json:"cluster_id"`
	Severity               AlertSeverity              `json:"severity"`
	Enabled                *bool                      `json:"enabled"`
	CooldownMinutes        *int                       `json:"cooldown_minutes"`
	SendRecovery           *bool                      `json:"send_recovery"`
	PromQL                 string                     `json:"promql"`
	Conditions             []*AlertPolicyConditionDTO `json:"conditions"`
	NotificationChannelIDs []uint                     `json:"notification_channel_ids"`
	ReceiverUserIDs        []uint64                   `json:"receiver_user_ids"`
}

UpsertAlertPolicyRequest represents create/update payload for one alert policy resource. UpsertAlertPolicyRequest 表示新增/更新统一告警策略的请求体。

func (*UpsertAlertPolicyRequest) Validate

func (r *UpsertAlertPolicyRequest) Validate() error

Validate validates alert policy request values. Validate 校验统一告警策略请求参数。

type UpsertNotificationChannelRequest

type UpsertNotificationChannelRequest struct {
	Name        string                     `json:"name"`
	Type        NotificationChannelType    `json:"type"`
	Enabled     *bool                      `json:"enabled"`
	Endpoint    string                     `json:"endpoint"`
	Secret      string                     `json:"secret"`
	Config      *NotificationChannelConfig `json:"config,omitempty"`
	Description string                     `json:"description"`
}

UpsertNotificationChannelRequest represents create/update channel payload. UpsertNotificationChannelRequest 表示新增/更新通知渠道请求。

func (*UpsertNotificationChannelRequest) Validate

Validate validates request values. Validate 校验通知渠道请求参数。

type UpsertNotificationRouteRequest

type UpsertNotificationRouteRequest struct {
	Name               string `json:"name"`
	Enabled            *bool  `json:"enabled"`
	SourceType         string `json:"source_type"`
	ClusterID          string `json:"cluster_id"`
	Severity           string `json:"severity"`
	RuleKey            string `json:"rule_key"`
	ChannelID          uint   `json:"channel_id"`
	SendResolved       *bool  `json:"send_resolved"`
	MuteIfAcknowledged *bool  `json:"mute_if_acknowledged"`
	MuteIfSilenced     *bool  `json:"mute_if_silenced"`
}

UpsertNotificationRouteRequest represents create/update route payload. UpsertNotificationRouteRequest 表示新增/更新通知路由请求。

func (*UpsertNotificationRouteRequest) Validate

func (r *UpsertNotificationRouteRequest) Validate() error

Validate validates notification route request. Validate 验证通知路由请求参数。

type WebhookAlert

type WebhookAlert struct {
	Status       string            `json:"status"`
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     time.Time         `json:"startsAt"`
	EndsAt       time.Time         `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
	Fingerprint  string            `json:"fingerprint"`
}

WebhookAlert represents one alert item in webhook payload. WebhookAlert 表示 webhook 中的单条告警。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL