Documentation ¶
Index ¶
Constants ¶
const ( UnknownType = "unknown" ThresholdType = "threshold" )
Rule types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { RuleID string `json:"ruleId"` Ingress string `json:"ingress"` Service string `json:"service"` Points []Point `json:"points"` Logs []byte `json:"logs"` Threshold *Threshold `json:"threshold"` }
Alert contains alert information.
type Backend ¶
type Backend interface { GetRules(ctx context.Context) ([]Rule, error) PreflightAlerts(ctx context.Context, alerts []Alert) ([]Alert, error) SendAlerts(ctx context.Context, alerts []Alert) error }
Backend is capable of serving rules and sending alerts.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the alerting service.
func (*Client) PreflightAlerts ¶
PreflightAlerts sends alert descriptors to the server and returns which alerts to send.
type DataPointsFinder ¶
type DataPointsFinder interface { FindByIngressAndService(table, ingress, service string, from, to time.Time) (metrics.DataPoints, error) FindByService(table, service string, from, to time.Time) metrics.DataPoints FindByIngress(table, ingress string, from, to time.Time) metrics.DataPoints }
DataPointsFinder is capable of finding data points for given criteria.
type LogProvider ¶
type LogProvider interface {
GetServiceLogs(ctx context.Context, namespace, name string, lines, maxLen int) ([]byte, error)
}
LogProvider implements an object that can provide logs for a service.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages rule synchronization and scheduling.
func NewManager ¶
func NewManager(backend Backend, procs map[string]Processor, refreshInterval, schedulerInterval time.Duration) *Manager
NewManager returns an alert manager. The alertRefreshInterval is the interval to fetch configuration, including alert rules. The alertSchedulerInterval is the interval at which the scheduler runs rule checks.
type Rule ¶
type Rule struct { ID string `json:"id"` Ingress string `json:"ingress"` Service string `json:"service"` Threshold *Threshold `json:"threshold"` }
Rule defines evaluation configuration for alerting on metrics.
type Threshold ¶
type Threshold struct { Metric string `json:"metric"` Condition ThresholdCondition `json:"condition"` Occurrence int `json:"occurrence"` TimeRange time.Duration `json:"timeRange"` }
Threshold contains a threshold and its direction.
func (Threshold) Granularity ¶
Granularity returns the metrics point granularity.
type ThresholdCondition ¶
ThresholdCondition contains a threshold condition.
type ThresholdProcessor ¶
type ThresholdProcessor struct {
// contains filtered or unexported fields
}
ThresholdProcessor processes threshold rules.
func NewThresholdProcessor ¶
func NewThresholdProcessor(dataPoints DataPointsFinder, logs LogProvider) *ThresholdProcessor
NewThresholdProcessor returns a threshold processor.