investigate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package investigate merges the signals that explain a spike (deploys, config changes, restarts, resource saturation) into one ordered timeline.

Index

Constants

View Source
const (
	KindRestart    = "restart"
	KindSaturation = "saturation"
)

Kinds added on top of changes.Kind.

View Source
const (
	SeverityInfo     = "info"
	SeverityWarning  = "warning"
	SeverityCritical = "critical"
)

Severity of a timeline event.

View Source
const (
	EnvSaturationCPU    = "APP_SATURATION_CPU_PERCENT"
	EnvSaturationMemory = "APP_SATURATION_MEMORY_PERCENT"
	EnvSaturationMinGap = "APP_SATURATION_MIN_SAMPLES"
)

Saturation env vars and defaults.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	At          time.Time `json:"at"`
	Kind        string    `json:"kind"`
	Severity    string    `json:"severity"`
	Title       string    `json:"title"`
	Detail      string    `json:"detail,omitempty"`
	Ref         string    `json:"ref,omitempty"`
	LikelyCause bool      `json:"likely_cause,omitempty"`
}

Event is one entry of the What changed timeline.

func FromChanges

func FromChanges(cs []changes.Change) []Event

FromChanges converts aggregator output into timeline events.

func Merge

func Merge(lists ...[]Event) []Event

Merge combines event lists into one timeline, oldest first. Ties order by kind rank (causes before symptoms) then title, so output is deterministic.

func RestartEvents

func RestartEvents(samples []telemetry.Sample, gap time.Duration) []Event

RestartEvents turns restart samples into events. Restarts closer together than gap collapse into one event whose title carries the count.

func SaturationEvents

func SaturationEvents(cpu, memUsage, memLimit []telemetry.Sample, th Thresholds) []Event

SaturationEvents finds sustained CPU and memory pressure. cpu is a percent series; memUsage and memLimit are bytes series sampled at the same times (a missing or zero limit skips memory).

func Window

func Window(events []Event, from, to time.Time) []Event

Window clamps events to [from, to].

type Thresholds

type Thresholds struct {
	CPUPercent    float64
	MemoryPercent float64
	MinSamples    int
}

Thresholds are the saturation limits in percent.

func ThresholdsFromEnv

func ThresholdsFromEnv() Thresholds

ThresholdsFromEnv reads the saturation limits from the environment.

Jump to

Keyboard shortcuts

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