monitoring

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 12 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        `json:"id"`
	Name       string        `json:"name"`
	Message    string        `json:"message"`
	Severity   AlertSeverity `json:"severity"`
	Metric     string        `json:"metric"`
	Value      float64       `json:"value"`
	Threshold  float64       `json:"threshold"`
	Timestamp  time.Time     `json:"timestamp"`
	Resolved   bool          `json:"resolved"`
	ResolvedAt *time.Time    `json:"resolved_at,omitempty"`
}

Alert represents a monitoring alert

type AlertManager

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

AlertManager manages alerts and notifications

func NewAlertManager

func NewAlertManager(config *MonitoringConfig, logger logger.Logger) *AlertManager

NewAlertManager creates a new alert manager

func (*AlertManager) GetActiveAlerts

func (am *AlertManager) GetActiveAlerts() []*Alert

GetActiveAlerts returns all active alerts

func (*AlertManager) ResolveAlert

func (am *AlertManager) ResolveAlert(alertID string)

ResolveAlert resolves an active alert

func (*AlertManager) Start

func (am *AlertManager) Start(ctx context.Context)

Start starts the alert manager

func (*AlertManager) TriggerAlert

func (am *AlertManager) TriggerAlert(alert *Alert)

TriggerAlert triggers a new alert

type AlertNotifier

type AlertNotifier interface {
	Name() string
	SendAlert(alert *Alert) error
}

AlertNotifier interface for alert notifications

type AlertSeverity

type AlertSeverity string

AlertSeverity represents alert severity levels

const (
	AlertSeverityInfo     AlertSeverity = "info"
	AlertSeverityWarning  AlertSeverity = "warning"
	AlertSeverityError    AlertSeverity = "error"
	AlertSeverityCritical AlertSeverity = "critical"
)

type CacheHealthCheck

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

CacheHealthCheck checks cache connectivity

func (*CacheHealthCheck) Check

func (chc *CacheHealthCheck) Check(ctx context.Context) HealthStatus

func (*CacheHealthCheck) Name

func (chc *CacheHealthCheck) Name() string

type CustomMetricConfig

type CustomMetricConfig struct {
	Name      string        `yaml:"name" json:"name"`
	Type      string        `yaml:"type" json:"type"`
	Threshold float64       `yaml:"threshold" json:"threshold"`
	Interval  time.Duration `yaml:"interval" json:"interval"`
}

CustomMetricConfig defines custom metric configuration

type DatabaseHealthCheck

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

DatabaseHealthCheck checks database connectivity

func (*DatabaseHealthCheck) Check

func (*DatabaseHealthCheck) Name

func (dhc *DatabaseHealthCheck) Name() string

type DiskSpaceHealthCheck

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

DiskSpaceHealthCheck checks available disk space

func (*DiskSpaceHealthCheck) Check

func (*DiskSpaceHealthCheck) Name

func (dshc *DiskSpaceHealthCheck) Name() string

type EmailConfig

type EmailConfig struct {
	SMTPHost    string   `yaml:"smtp_host" json:"smtp_host"`
	SMTPPort    int      `yaml:"smtp_port" json:"smtp_port"`
	Username    string   `yaml:"username" json:"username"`
	Password    string   `yaml:"password" json:"password"`
	FromAddress string   `yaml:"from_address" json:"from_address"`
	ToAddresses []string `yaml:"to_addresses" json:"to_addresses"`
}

EmailConfig holds email notification configuration

type EmailNotifier

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

EmailNotifier sends alerts via email

func NewEmailNotifier

func NewEmailNotifier(config *EmailConfig) *EmailNotifier

NewEmailNotifier creates a new email notifier

func (*EmailNotifier) Name

func (en *EmailNotifier) Name() string

func (*EmailNotifier) SendAlert

func (en *EmailNotifier) SendAlert(alert *Alert) error

type HealthCheck

type HealthCheck interface {
	Name() string
	Check(ctx context.Context) HealthStatus
}

HealthCheck interface for health checks

type HealthStatus

type HealthStatus struct {
	Healthy   bool                   `json:"healthy"`
	Message   string                 `json:"message"`
	Details   map[string]interface{} `json:"details,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
}

HealthStatus represents the status of a health check

type MemoryHealthCheck

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

MemoryHealthCheck checks memory usage

func (*MemoryHealthCheck) Check

func (*MemoryHealthCheck) Name

func (mhc *MemoryHealthCheck) Name() string

type MonitoringConfig

type MonitoringConfig struct {
	Enabled         bool                 `yaml:"enabled" json:"enabled"`
	MetricsInterval time.Duration        `yaml:"metrics_interval" json:"metrics_interval"`
	HealthInterval  time.Duration        `yaml:"health_interval" json:"health_interval"`
	SlackConfig     *SlackConfig         `yaml:"slack" json:"slack"`
	EmailConfig     *EmailConfig         `yaml:"email" json:"email"`
	WebhookURL      string               `yaml:"webhook_url" json:"webhook_url"`
	CustomMetrics   []CustomMetricConfig `yaml:"custom_metrics" json:"custom_metrics"`
	AlertThresholds map[string]float64   `yaml:"alert_thresholds" json:"alert_thresholds"`
}

MonitoringConfig holds monitoring configuration

type MonitoringService

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

MonitoringService provides enterprise monitoring capabilities

func NewMonitoringService

func NewMonitoringService(config *MonitoringConfig, logger logger.Logger) *MonitoringService

NewMonitoringService creates a new monitoring service

func (*MonitoringService) GetMetrics added in v1.2.0

func (ms *MonitoringService) GetMetrics() metrics.MetricSnapshot

GetMetrics returns current metrics snapshot

func (*MonitoringService) GetSystemHealth

func (ms *MonitoringService) GetSystemHealth() SystemHealth

GetSystemHealth returns current system health

func (*MonitoringService) HTTPHandler

func (ms *MonitoringService) HTTPHandler() http.Handler

HTTPHandler returns an HTTP handler for monitoring endpoints

func (*MonitoringService) RecordMetric

func (ms *MonitoringService) RecordMetric(name, metricType string, value float64)

RecordMetric records a custom metric

func (*MonitoringService) RegisterHealthCheck

func (ms *MonitoringService) RegisterHealthCheck(check HealthCheck)

RegisterHealthCheck registers a health check

func (*MonitoringService) Start

func (ms *MonitoringService) Start(ctx context.Context) error

Start starts the monitoring service

func (*MonitoringService) Stop

func (ms *MonitoringService) Stop()

Stop stops the monitoring service

type SlackConfig

type SlackConfig struct {
	WebhookURL string `yaml:"webhook_url" json:"webhook_url"`
	Channel    string `yaml:"channel" json:"channel"`
	Username   string `yaml:"username" json:"username"`
}

SlackConfig holds Slack notification configuration

type SlackNotifier

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

SlackNotifier sends alerts to Slack

func NewSlackNotifier

func NewSlackNotifier(config *SlackConfig) *SlackNotifier

NewSlackNotifier creates a new Slack notifier

func (*SlackNotifier) Name

func (sn *SlackNotifier) Name() string

func (*SlackNotifier) SendAlert

func (sn *SlackNotifier) SendAlert(alert *Alert) error

type SystemHealth

type SystemHealth struct {
	OverallStatus string                  `json:"overall_status"`
	Checks        map[string]HealthStatus `json:"checks"`
	Metrics       metrics.MetricSnapshot  `json:"metrics"`
	Timestamp     time.Time               `json:"timestamp"`
}

SystemHealth represents overall system health

type WebhookNotifier

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

WebhookNotifier sends alerts to a webhook URL

func NewWebhookNotifier

func NewWebhookNotifier(webhookURL string) *WebhookNotifier

NewWebhookNotifier creates a new webhook notifier

func (*WebhookNotifier) Name

func (wn *WebhookNotifier) Name() string

func (*WebhookNotifier) SendAlert

func (wn *WebhookNotifier) SendAlert(alert *Alert) error

Jump to

Keyboard shortcuts

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