monitoring

package
v0.0.0-...-89e7f00 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID        string
	Rule      string
	Level     AlertLevel
	Message   string
	Timestamp time.Time
	NodeID    string
	NodeType  string
}

Alert 告警

type AlertChannel

type AlertChannel interface {
	Send(alert Alert) error
}

AlertChannel 告警通道

type AlertLevel

type AlertLevel int

AlertLevel 告警级别

const (
	AlertLevelInfo AlertLevel = iota
	AlertLevelWarning
	AlertLevelError
	AlertLevelCritical
)

type AlertManager

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

AlertManager 告警管理器

func NewAlertManager

func NewAlertManager() *AlertManager

NewAlertManager 创建告警管理器

func (*AlertManager) AddChannel

func (am *AlertManager) AddChannel(channel AlertChannel)

AddChannel 添加告警通道

func (*AlertManager) AddRule

func (am *AlertManager) AddRule(rule AlertRule)

AddRule 添加告警规则

func (*AlertManager) CheckRules

func (am *AlertManager) CheckRules(nodeID, nodeType string)

CheckRules 检查告警规则

func (*AlertManager) GetRecentAlerts

func (am *AlertManager) GetRecentAlerts(limit int) []Alert

GetRecentAlerts 获取最近的告警

type AlertRule

type AlertRule struct {
	Name      string
	Condition func() bool
	Message   string
	Level     AlertLevel
	Cooldown  time.Duration
	LastAlert time.Time
}

AlertRule 告警规则

type LogAlertChannel

type LogAlertChannel struct{}

LogAlertChannel 日志告警通道

func (*LogAlertChannel) Send

func (lac *LogAlertChannel) Send(alert Alert) error

Send 发送告警到日志

type MetricsCollector

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

MetricsCollector 指标收集器

func NewMetricsCollector

func NewMetricsCollector(nodeID, nodeType string) (*MetricsCollector, error)

NewMetricsCollector 创建指标收集器

func (*MetricsCollector) Collect

func (mc *MetricsCollector) Collect(ch chan<- prometheus.Metric)

Collect 实现prometheus.Collector接口

func (*MetricsCollector) Describe

func (mc *MetricsCollector) Describe(ch chan<- *prometheus.Desc)

Describe 实现prometheus.Collector接口

type MonitoringManager

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

MonitoringManager 监控管理器

func NewMonitoringManager

func NewMonitoringManager(nodeID, nodeType string, port int) (*MonitoringManager, error)

NewMonitoringManager 创建监控管理器

func (*MonitoringManager) RecordError

func (mm *MonitoringManager) RecordError(errorType string)

RecordError 记录错误指标

func (*MonitoringManager) RecordMessage

func (mm *MonitoringManager) RecordMessage(messageType string)

RecordMessage 记录消息指标

func (*MonitoringManager) RecordRequestDuration

func (mm *MonitoringManager) RecordRequestDuration(method, endpoint string, duration time.Duration)

RecordRequestDuration 记录请求时长

func (*MonitoringManager) SetActorCount

func (mm *MonitoringManager) SetActorCount(count int)

SetActorCount 设置Actor数量

func (*MonitoringManager) SetConnectionCount

func (mm *MonitoringManager) SetConnectionCount(count int)

SetConnectionCount 设置连接数

func (*MonitoringManager) Start

func (mm *MonitoringManager) Start() error

Start 启动监控服务

func (*MonitoringManager) Stop

func (mm *MonitoringManager) Stop() error

Stop 停止监控服务

Jump to

Keyboard shortcuts

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