Documentation
¶
Overview ¶
Package budgetalerts provides budget alerting capabilities for TokMan
Index ¶
- type AggregationType
- type Alert
- type AlertEvent
- type AlertStatus
- type ChannelType
- type Condition
- type EventType
- type Manager
- func (m *Manager) AcknowledgeAlert(id string) error
- func (m *Manager) CreateRule(config RuleConfig) (*Rule, error)
- func (m *Manager) DeleteRule(id string) error
- func (m *Manager) EvaluateRules(ctx context.Context) error
- func (m *Manager) GetActiveAlerts() []*Alert
- func (m *Manager) GetHistory(limit int) []AlertEvent
- func (m *Manager) GetRule(id string) (*Rule, error)
- func (m *Manager) ListRules() []*Rule
- func (m *Manager) RegisterChannel(channel NotificationChannel)
- func (m *Manager) ResolveAlert(id string, reason string) error
- func (m *Manager) SetMetricProvider(provider MetricProvider)
- func (m *Manager) UpdateRule(id string, config RuleConfig) error
- type MetricProvider
- type NotificationChannel
- type NotificationConfig
- type Operator
- type Rule
- type RuleConfig
- type RuleEvaluator
- type Severity
- type Thresholds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregationType ¶
type AggregationType string
AggregationType defines how to aggregate metrics
const ( AggAvg AggregationType = "avg" AggSum AggregationType = "sum" AggMin AggregationType = "min" AggMax AggregationType = "max" AggCount AggregationType = "count" AggLast AggregationType = "last" )
type Alert ¶
type Alert struct {
ID string
RuleID string
Name string
Description string
Status AlertStatus
Severity Severity
TriggeredAt time.Time
ResolvedAt *time.Time
Value float64
Threshold float64
Message string
Metadata map[string]string
}
Alert represents a budget alert instance
type AlertEvent ¶
type AlertEvent struct {
Timestamp time.Time
AlertID string
RuleID string
Type EventType
Message string
}
AlertEvent represents an alert event in history
type AlertStatus ¶
type AlertStatus string
AlertStatus represents alert status
const ( AlertStatusActive AlertStatus = "active" AlertStatusResolved AlertStatus = "resolved" AlertStatusAcknowledged AlertStatus = "acknowledged" AlertStatusMuted AlertStatus = "muted" )
type ChannelType ¶
type ChannelType string
ChannelType defines notification channel types
const ( ChannelEmail ChannelType = "email" ChannelSlack ChannelType = "slack" ChannelWebhook ChannelType = "webhook" ChannelPagerDuty ChannelType = "pagerduty" ChannelConsole ChannelType = "console" )
type Condition ¶
type Condition struct {
Metric string
Operator Operator
Value float64
Duration time.Duration
Aggregation AggregationType
}
Condition defines when to trigger an alert
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages budget alerts
func (*Manager) AcknowledgeAlert ¶
AcknowledgeAlert acknowledges an alert
func (*Manager) CreateRule ¶
func (m *Manager) CreateRule(config RuleConfig) (*Rule, error)
CreateRule creates a new alert rule
func (*Manager) DeleteRule ¶
DeleteRule deletes a rule
func (*Manager) EvaluateRules ¶
EvaluateRules evaluates all enabled rules
func (*Manager) GetActiveAlerts ¶
GetActiveAlerts returns all active alerts
func (*Manager) GetHistory ¶
func (m *Manager) GetHistory(limit int) []AlertEvent
GetHistory returns alert history
func (*Manager) RegisterChannel ¶
func (m *Manager) RegisterChannel(channel NotificationChannel)
RegisterChannel registers a notification channel
func (*Manager) ResolveAlert ¶
ResolveAlert manually resolves an alert
func (*Manager) SetMetricProvider ¶
func (m *Manager) SetMetricProvider(provider MetricProvider)
SetMetricProvider sets the metric provider for evaluation
func (*Manager) UpdateRule ¶
func (m *Manager) UpdateRule(id string, config RuleConfig) error
UpdateRule updates an existing rule
type MetricProvider ¶
type MetricProvider interface {
GetMetric(name string, duration time.Duration, agg AggregationType) (float64, error)
GetCurrentValue(name string) (float64, error)
}
MetricProvider provides metric values
type NotificationChannel ¶
type NotificationChannel struct {
ID string
Name string
Type ChannelType
Config map[string]string
}
NotificationChannel defines a notification channel
type NotificationConfig ¶
NotificationConfig defines how to send notifications
type Rule ¶
type Rule struct {
ID string
Name string
Description string
Enabled bool
Condition Condition
Thresholds Thresholds
Notifications NotificationConfig
Cooldown time.Duration
AutoResolve bool
// contains filtered or unexported fields
}
Rule defines an alert rule
type RuleConfig ¶
type RuleConfig struct {
Name string
Description string
Enabled bool
Condition Condition
Thresholds Thresholds
Notifications NotificationConfig
Cooldown time.Duration
AutoResolve bool
}
RuleConfig holds rule configuration
type RuleEvaluator ¶
type RuleEvaluator struct {
// contains filtered or unexported fields
}
RuleEvaluator evaluates alert rules
type Thresholds ¶
Thresholds defines multi-level thresholds