Documentation
¶
Overview ¶
Package intelligence derives anomalies and log patterns from telemetry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anomaly ¶
type Anomaly struct {
Type AnomalyType `json:"type"` // error_spike, latency_degradation, volume_change
ServiceName string `json:"service_name"` // Affected service
Metric string `json:"metric"` // error_rate, p95_latency, span_count
Current float64 `json:"current"` // Current value
Baseline float64 `json:"baseline"` // Expected/historical value
ZScore float64 `json:"z_score"` // Statistical significance
DetectedAt time.Time `json:"detected_at"` // When anomaly was detected
Description string `json:"description"` // Human-readable description
WindowStart time.Time `json:"-"` // Evaluated interval, inclusive
WindowEnd time.Time `json:"-"` // Evaluated interval, exclusive
}
Anomaly represents a detected statistical anomaly
type AnomalyType ¶
type AnomalyType string
AnomalyType represents the type of anomaly detected
const ( AnomalyErrorSpike AnomalyType = "error_spike" AnomalyLatencyDegradation AnomalyType = "latency_degradation" AnomalyVolumeChange AnomalyType = "volume_change" AnomalyErrorRateChange AnomalyType = "error_rate_change" )
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector runs intelligence detection on observability data
func NewDetector ¶
func NewDetector(duck Engine, config DetectorConfig) *Detector
NewDetector creates a new intelligence detector
func (*Detector) GenerateSnapshot ¶
GenerateSnapshot generates a complete intelligence snapshot
func (*Detector) LatestSnapshot ¶
LatestSnapshot returns the most recent intelligence snapshot, or nil if none.
type DetectorConfig ¶
type DetectorConfig struct {
Enabled bool `json:"enabled"`
CheckInterval time.Duration `json:"check_interval"` // How often to run detection
LookbackWindow time.Duration `json:"lookback_window"` // Time window to analyze
ErrorRateThreshold float64 `json:"error_rate_threshold"` // Z-score threshold for errors
LatencyThreshold float64 `json:"latency_threshold"` // Z-score threshold for latency
VolumeThreshold float64 `json:"volume_threshold"` // Z-score threshold for volume
}
DetectorConfig holds configuration for the anomaly detector
func DefaultDetectorConfig ¶
func DefaultDetectorConfig() DetectorConfig
DefaultDetectorConfig returns sensible defaults
type Engine ¶
type Engine interface {
QueryContext(ctx context.Context, query string, args ...any) (queryrows.Rows, error)
DefaultNamespace() string
CompletedServiceRollupMinute(ctx context.Context) (time.Time, error)
RecordAnomalies(ctx context.Context, findings []annotations.Anomaly, at time.Time) error
}
Engine is the read and annotation surface the detector uses; *engine.Duck implements it.
type Insight ¶
type Insight struct {
Type string `json:"type"` // anomaly, trend
Severity string `json:"severity"` // info, warning, critical
Message string `json:"message"` // Description
}
Insight represents a generated insight about the system
type LogSample ¶
type LogSample struct {
Timestamp time.Time `json:"timestamp"`
Message string `json:"message"`
TraceID string `json:"trace_id,omitempty"`
}
LogSample represents a single log instance
type Pattern ¶
type Pattern struct {
Template string `json:"template"` // Log template with variables removed
Count int `json:"count"` // Number of occurrences
FirstSeen time.Time `json:"first_seen"` // First occurrence timestamp
LastSeen time.Time `json:"last_seen"` // Last occurrence timestamp
Severity string `json:"severity"` // WARN, ERROR, etc.
ServiceName string `json:"service_name"` // Service generating the logs
Summary string `json:"summary"` // LLM-generated summary
Samples []LogSample `json:"samples,omitempty"` // Sample log messages
}
Pattern represents a grouped log pattern with deduplication
type Snapshot ¶
type Snapshot struct {
GeneratedAt time.Time `json:"generated_at"`
Timeframe string `json:"timeframe"` // e.g., "last_15m"
Insights []Insight `json:"insights"`
Patterns []Pattern `json:"patterns"`
Anomalies []Anomaly `json:"anomalies"`
Summary string `json:"summary"` // Overall system health summary
HealthScore float64 `json:"health_score"` // 0-100, lower is worse
// contains filtered or unexported fields
}
Snapshot represents the current system intelligence state