Documentation
¶
Index ¶
- type AggregateSample
- type AppBaselineRow
- type ConfigBaselineRow
- type DriftTrackerRow
- type Fingerprint
- type IncidentOffender
- type IncidentRecord
- type Store
- func (s *Store) Close() error
- func (s *Store) GetFingerprint(fp string) (*Fingerprint, error)
- func (s *Store) GetIncident(id string) (*IncidentRecord, error)
- func (s *Store) GetOffenders(incidentID string) ([]IncidentOffender, error)
- func (s *Store) InsertAggregate(ts time.Time, summary AggregateSample) error
- func (s *Store) InsertIncident(e model.Event, fp string, offenders []model.ImpactScore) error
- func (s *Store) ListByFingerprint(fp string) ([]IncidentRecord, error)
- func (s *Store) ListIncidents(limit, offset int) ([]IncidentRecord, error)
- func (s *Store) LoadAppBaselines() ([]AppBaselineRow, error)
- func (s *Store) LoadConfigBaseline() ([]ConfigBaselineRow, error)
- func (s *Store) LoadDriftTrackers() ([]DriftTrackerRow, error)
- func (s *Store) Migrate() error
- func (s *Store) Prune(olderThan time.Time) (int, error)
- func (s *Store) SaveAppBaselines(rows []AppBaselineRow) error
- func (s *Store) SaveConfigBaseline(rows []ConfigBaselineRow) error
- func (s *Store) SaveDriftTrackers(rows []DriftTrackerRow) error
- func (s *Store) UpdateIncident(id string, e model.Event) error
- func (s *Store) UpsertFingerprint(fp Fingerprint) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateSample ¶
type AggregateSample struct {
Health string `json:"health"`
Score int `json:"score"`
CPUBusy float64 `json:"cpu_busy"`
MemPct float64 `json:"mem_pct"`
IOPSI float64 `json:"io_psi"`
TopPID int `json:"top_pid"`
TopComm string `json:"top_comm"`
}
AggregateSample is a 10-second aggregate row.
type AppBaselineRow ¶
type AppBaselineRow struct {
App string
Metric string
HourOfWeek int
Count int64
Mean float64
M2 float64
}
AppBaselineRow is one persisted Welford bucket. Lives in store/ to keep the engine→store import direction clean.
type ConfigBaselineRow ¶
type ConfigBaselineRow struct {
Key string
Value string
Domain string
FirstSeen time.Time
Acked bool
}
ConfigBaselineRow is one persisted config baseline entry (P4.2). first_seen is preserved across upserts; acked signals operator review.
type DriftTrackerRow ¶
type DriftTrackerRow struct {
Metric string
Window string // "short" | "long" | "ref"
Count int64
Mean float64
M2 float64
RefSet bool
}
DriftTrackerRow is one persisted Welford bucket within a drift window.
type Fingerprint ¶
type Fingerprint struct {
FP string `json:"fingerprint"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
Count int `json:"count"`
AvgDuration int `json:"avg_duration_sec"`
SymptomType string `json:"symptom_type"`
RootClass string `json:"root_class"`
TopOffender string `json:"top_offender"`
}
Fingerprint tracks recurring incident patterns.
type IncidentOffender ¶
type IncidentOffender struct {
IncidentID string `json:"incident_id"`
PID int `json:"pid"`
Comm string `json:"comm"`
Service string `json:"service,omitempty"`
ImpactScore float64 `json:"impact_score"`
CPUPct float64 `json:"cpu_pct"`
MemBytes uint64 `json:"mem_bytes"`
IOMBps float64 `json:"io_mbps"`
}
IncidentOffender is a stored per-incident offender.
type IncidentRecord ¶
type IncidentRecord struct {
ID string `json:"id"`
Fingerprint string `json:"fingerprint"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
DurationSec int `json:"duration_sec"`
PeakHealth string `json:"peak_health"`
Bottleneck string `json:"bottleneck"`
PeakScore int `json:"peak_score"`
CulpritProcess string `json:"culprit_process,omitempty"`
CulpritPID int `json:"culprit_pid,omitempty"`
CulpritCgroup string `json:"culprit_cgroup,omitempty"`
CausalChain string `json:"causal_chain,omitempty"`
Narrative string `json:"narrative,omitempty"`
EvidenceJSON string `json:"evidence_json,omitempty"`
PeakCPU float64 `json:"peak_cpu"`
PeakMem float64 `json:"peak_mem"`
PeakIOPSI float64 `json:"peak_io_psi"`
}
IncidentRecord is a stored incident row.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides SQLite-backed persistence for incidents and aggregates.
func (*Store) GetFingerprint ¶
func (s *Store) GetFingerprint(fp string) (*Fingerprint, error)
GetFingerprint retrieves a fingerprint record.
func (*Store) GetIncident ¶
func (s *Store) GetIncident(id string) (*IncidentRecord, error)
GetIncident retrieves a single incident by ID.
func (*Store) GetOffenders ¶
func (s *Store) GetOffenders(incidentID string) ([]IncidentOffender, error)
GetOffenders returns offenders for an incident.
func (*Store) InsertAggregate ¶
func (s *Store) InsertAggregate(ts time.Time, summary AggregateSample) error
InsertAggregate inserts a 10-second aggregate sample.
func (*Store) InsertIncident ¶
InsertIncident inserts a new incident with its offenders.
func (*Store) ListByFingerprint ¶
func (s *Store) ListByFingerprint(fp string) ([]IncidentRecord, error)
ListByFingerprint returns incidents matching a fingerprint.
func (*Store) ListIncidents ¶
func (s *Store) ListIncidents(limit, offset int) ([]IncidentRecord, error)
ListIncidents returns incidents ordered by start_time descending.
func (*Store) LoadAppBaselines ¶
func (s *Store) LoadAppBaselines() ([]AppBaselineRow, error)
LoadAppBaselines reads every persisted baseline back. Caller seeds its in-memory store from the result.
func (*Store) LoadConfigBaseline ¶
func (s *Store) LoadConfigBaseline() ([]ConfigBaselineRow, error)
LoadConfigBaseline reads all config baseline rows back.
func (*Store) LoadDriftTrackers ¶
func (s *Store) LoadDriftTrackers() ([]DriftTrackerRow, error)
LoadDriftTrackers reads every persisted drift tracker back.
func (*Store) SaveAppBaselines ¶
func (s *Store) SaveAppBaselines(rows []AppBaselineRow) error
SaveAppBaselines upserts all rows in one transaction.
func (*Store) SaveConfigBaseline ¶
func (s *Store) SaveConfigBaseline(rows []ConfigBaselineRow) error
SaveConfigBaseline upserts config baseline rows in one transaction. On conflict the value, domain, and acked fields are updated but first_seen is left unchanged (preserving when the key was first observed).
func (*Store) SaveDriftTrackers ¶
func (s *Store) SaveDriftTrackers(rows []DriftTrackerRow) error
SaveDriftTrackers upserts all rows in one transaction.
func (*Store) UpdateIncident ¶
UpdateIncident updates end time and duration for a closed incident.
func (*Store) UpsertFingerprint ¶
func (s *Store) UpsertFingerprint(fp Fingerprint) error
UpsertFingerprint inserts or updates a fingerprint record.