{"modulePath":"github.com/labstack/pitot","version":"v0.0.0-20261123231833-0301fe8e3bdc","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package intelligence\n\nPackage intelligence derives anomalies and log patterns from telemetry.\n\n## Types\n\n```go\ntype Anomaly struct {\n\tType        AnomalyType `json:\"type\"`         // error_spike, latency_degradation, volume_change\n\tServiceName string      `json:\"service_name\"` // Affected service\n\tMetric      string      `json:\"metric\"`       // error_rate, p95_latency, span_count\n\tCurrent     float64     `json:\"current\"`      // Current value\n\tBaseline    float64     `json:\"baseline\"`     // Expected/historical value\n\tZScore      float64     `json:\"z_score\"`      // Statistical significance\n\tDetectedAt  time.Time   `json:\"detected_at\"`  // When anomaly was detected\n\tDescription string      `json:\"description\"`  // Human-readable description\n\tWindowStart time.Time   `json:\"-\"`            // Evaluated interval, inclusive\n\tWindowEnd   time.Time   `json:\"-\"`            // Evaluated interval, exclusive\n}\n```\nAnomaly represents a detected statistical anomaly\n\n```go\ntype AnomalyType string\n```\nAnomalyType represents the type of anomaly detected\n\n```go\nconst (\n\tAnomalyErrorSpike         AnomalyType = \"error_spike\"\n\tAnomalyLatencyDegradation AnomalyType = \"latency_degradation\"\n\tAnomalyVolumeChange       AnomalyType = \"volume_change\"\n\tAnomalyErrorRateChange    AnomalyType = \"error_rate_change\"\n)\n```\n\n```go\ntype Detector struct {\n\t// contains filtered or unexported fields\n}\n```\nDetector runs intelligence detection on observability data\n\n```go\nfunc NewDetector(duck Engine, config DetectorConfig) *Detector\n```\nNewDetector creates a new intelligence detector\n\n```go\nfunc (d *Detector) GenerateSnapshot(ctx context.Context) (Snapshot, error)\n```\nGenerateSnapshot generates a complete intelligence snapshot\n\n```go\nfunc (d *Detector) LatestSnapshot() *Snapshot\n```\nLatestSnapshot returns the most recent intelligence snapshot, or nil if none.\n\n```go\nfunc (d *Detector) Run(ctx context.Context)\n```\nRun starts the detection loop\n\n```go\ntype DetectorConfig struct {\n\tEnabled            bool          `json:\"enabled\"`\n\tCheckInterval      time.Duration `json:\"check_interval\"`       // How often to run detection\n\tLookbackWindow     time.Duration `json:\"lookback_window\"`      // Time window to analyze\n\tErrorRateThreshold float64       `json:\"error_rate_threshold\"` // Z-score threshold for errors\n\tLatencyThreshold   float64       `json:\"latency_threshold\"`    // Z-score threshold for latency\n\tVolumeThreshold    float64       `json:\"volume_threshold\"`     // Z-score threshold for volume\n}\n```\nDetectorConfig holds configuration for the anomaly detector\n\n```go\nfunc DefaultDetectorConfig() DetectorConfig\n```\nDefaultDetectorConfig returns sensible defaults\n\n```go\ntype Engine interface {\n\tQueryContext(ctx context.Context, query string, args ...any) (queryrows.Rows, error)\n\tDefaultNamespace() string\n\tCompletedServiceRollupMinute(ctx context.Context) (time.Time, error)\n\tRecordAnomalies(ctx context.Context, findings []annotations.Anomaly, at time.Time) error\n}\n```\nEngine is the read and annotation surface the detector uses; \\*engine.Duck implements it.\n\n```go\ntype Insight struct {\n\tType     string `json:\"type\"`     // anomaly, trend\n\tSeverity string `json:\"severity\"` // info, warning, critical\n\tMessage  string `json:\"message\"`  // Description\n}\n```\nInsight represents a generated insight about the system\n\n```go\ntype LogSample struct {\n\tTimestamp time.Time `json:\"timestamp\"`\n\tMessage   string    `json:\"message\"`\n\tTraceID   string    `json:\"trace_id,omitempty\"`\n}\n```\nLogSample represents a single log instance\n\n```go\ntype Pattern struct {\n\tTemplate    string      `json:\"template\"`          // Log template with variables removed\n\tCount       int         `json:\"count\"`             // Number of occurrences\n\tFirstSeen   time.Time   `json:\"first_seen\"`        // First occurrence timestamp\n\tLastSeen    time.Time   `json:\"last_seen\"`         // Last occurrence timestamp\n\tSeverity    string      `json:\"severity\"`          // WARN, ERROR, etc.\n\tServiceName string      `json:\"service_name\"`      // Service generating the logs\n\tSummary     string      `json:\"summary\"`           // LLM-generated summary\n\tSamples     []LogSample `json:\"samples,omitempty\"` // Sample log messages\n}\n```\nPattern represents a grouped log pattern with deduplication\n\n```go\ntype Snapshot struct {\n\tGeneratedAt time.Time `json:\"generated_at\"`\n\tTimeframe   string    `json:\"timeframe\"` // e.g., \"last_15m\"\n\tInsights    []Insight `json:\"insights\"`\n\tPatterns    []Pattern `json:\"patterns\"`\n\tAnomalies   []Anomaly `json:\"anomalies\"`\n\tSummary     string    `json:\"summary\"`      // Overall system health summary\n\tHealthScore float64   `json:\"health_score\"` // 0-100, lower is worse\n\t// contains filtered or unexported fields\n}\n```\nSnapshot represents the current system intelligence state\n\n","path":"github.com/labstack/pitot/internal/intelligence","name":"intelligence","synopsis":"Package intelligence derives anomalies and log patterns from telemetry.","isRedistributable":true}
