intelligence

package
v0.0.0-...-0301fe8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func (d *Detector) GenerateSnapshot(ctx context.Context) (Snapshot, error)

GenerateSnapshot generates a complete intelligence snapshot

func (*Detector) LatestSnapshot

func (d *Detector) LatestSnapshot() *Snapshot

LatestSnapshot returns the most recent intelligence snapshot, or nil if none.

func (*Detector) Run

func (d *Detector) Run(ctx context.Context)

Run starts the detection loop

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

Jump to

Keyboard shortcuts

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